Skip to content

Commit

Permalink
merge r3064 from branch 2.0 to trunk
Browse files Browse the repository at this point in the history
bug 912 fixed: we need an extra original_sum to pwg.images.add API method to
check photo existence. Using the file_sum was a bad idea.


git-svn-id: http://piwigo.org/svn/trunk@3065 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
plegall committed Jan 8, 2009
1 parent ff0dfb9 commit 83275fd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/ws_functions.inc.php
Expand Up @@ -909,7 +909,7 @@ function ws_images_add($params, &$service)
SELECT
COUNT(*) AS counter
FROM '.IMAGES_TABLE.'
WHERE md5sum = \''.$params['file_sum'].'\'
WHERE md5sum = \''.$params['original_sum'].'\'
;';
list($counter) = mysql_fetch_row(pwg_query($query));
if ($counter != 0) {
Expand Down Expand Up @@ -1088,7 +1088,7 @@ function ws_images_add($params, &$service)
'filesize' => floor(filesize($file_path)/1024),
'width' => $width,
'height' => $height,
'md5sum' => $params['file_sum'],
'md5sum' => $params['original_sum'],
);

$info_columns = array(
Expand Down
8 changes: 6 additions & 2 deletions tools/piwigo_remote.pl
Expand Up @@ -11,7 +11,7 @@
my %opt = ();
GetOptions(
\%opt,
qw/action=s file=s thumbnail=s high=s categories=s define=s%/
qw/action=s file=s thumbnail=s high=s original=s categories=s define=s%/
);

our $ua = LWP::UserAgent->new;
Expand Down Expand Up @@ -48,6 +48,8 @@
use Digest::MD5::File qw/file_md5_hex/;
use File::Slurp;

my $original_sum = file_md5_hex($opt{original});

my $file_content = encode_base64(read_file($opt{file}));
my $file_sum = file_md5_hex($opt{file});

Expand All @@ -56,6 +58,7 @@

$form = {
method => 'pwg.images.add',
original_sum => $original_sum,
file_sum => $file_sum,
file_content => $file_content,
thumbnail_sum => $thumbnail_sum,
Expand Down Expand Up @@ -84,7 +87,8 @@
print "\n";

# use Data::Dumper;
# print Dumper($response);
# print Dumper($response->content);
# print Dumper(from_json($response->content));

if ($response->is_success) {
print "upload successful\n";
Expand Down
1 change: 1 addition & 0 deletions ws.php
Expand Up @@ -182,6 +182,7 @@ function ws_addDefaultMethods( $arr )
'thumbnail_sum' => array(),
'high_content' => array('default' => null),
'high_sum' => array('default' => null),
'original_sum' => array(),
'name' => array('default' => null),
'author' => array('default' => null),
'date_creation' => array('default' => null),
Expand Down

0 comments on commit 83275fd

Please sign in to comment.