From 48c1eef07e14e1d7a25a73fc02fabd628130fa9e Mon Sep 17 00:00:00 2001 From: plegall Date: Thu, 8 Jan 2009 23:31:49 +0000 Subject: 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/branches/2.0@3064 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/ws_functions.inc.php | 4 ++-- tools/piwigo_remote.pl | 8 ++++++-- ws.php | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php index 5c5d23b7a..fd87ef02e 100644 --- a/include/ws_functions.inc.php +++ b/include/ws_functions.inc.php @@ -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) { @@ -1088,7 +1088,7 @@ SELECT 'filesize' => floor(filesize($file_path)/1024), 'width' => $width, 'height' => $height, - 'md5sum' => $params['file_sum'], + 'md5sum' => $params['original_sum'], ); $info_columns = array( diff --git a/tools/piwigo_remote.pl b/tools/piwigo_remote.pl index 2a3876b87..6cd558cd1 100644 --- a/tools/piwigo_remote.pl +++ b/tools/piwigo_remote.pl @@ -11,7 +11,7 @@ use Encode qw/is_utf8 decode/; 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; @@ -48,6 +48,8 @@ if ($opt{action} eq 'pwg.images.add') { 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}); @@ -56,6 +58,7 @@ if ($opt{action} eq 'pwg.images.add') { $form = { method => 'pwg.images.add', + original_sum => $original_sum, file_sum => $file_sum, file_content => $file_content, thumbnail_sum => $thumbnail_sum, @@ -84,7 +87,8 @@ if ($opt{action} eq 'pwg.images.add') { 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"; diff --git a/ws.php b/ws.php index fc920f3f4..7867f8001 100644 --- a/ws.php +++ b/ws.php @@ -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), -- cgit v1.2.3