Skip to content

Commit

Permalink
allow moving images between servers, fixes #4880
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanegigandet committed Feb 18, 2021
1 parent 68f4332 commit abb1aff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 11 additions & 1 deletion cgi/product_image_move.pl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@
my $code = normalize_code(param('code'));
my $imgids = param('imgids');
my $move_to = param('move_to_override');
if ($move_to ne 'trash') {
if ($move_to =~ /^(off|obf|opf|opff)$/) {
$move_to .= ':' . $code;
}
elsif ($move_to ne 'trash') {
$move_to = normalize_code($move_to);
}
my $copy_data = param('copy_data_override');
Expand Down Expand Up @@ -189,6 +192,13 @@
}

$response{url} = product_url($move_to);

# URL on another server?
my $server = server_for_product_id($move_to);
if (defined $server) {
my $url = "https://" . $subdomain . "." . $options{other_servers}{$server}{$domain} . $response{url};
}

$response{link} = '<a href="' . $response{url} . '">' . $move_to . '</a>';
}

Expand Down
3 changes: 1 addition & 2 deletions lib/ProductOpener/Images.pm
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ sub process_image_move($$$$) {
my $ownerid = shift;

# move images only to trash or another valid barcode (number)
if (($move_to ne 'trash') and ($move_to !~ /^\d+$/)) {
if (($move_to ne 'trash') and ($move_to !~ /^((off|obf|opf|opff):)?\d+$/)) {
return "invalid barcode number: $move_to";
}

Expand Down Expand Up @@ -877,7 +877,6 @@ sub process_image_move($$$$) {
$log->info("moving source image to deleted images directory", { source_path => "$www_root/images/products/$path/$imgid.jpg", destination_path => "$data_root/deleted.images/product.$code.$imgid.jpg" });

move("$www_root/images/products/$path/$imgid.jpg", "$data_root/deleted.images/product.$code.$imgid.jpg");
move("$www_root/images/products/$path/$imgid.json", "$data_root/deleted.images/product.$code.$imgid.json");
move("$www_root/images/products/$path/$imgid.$thumb_size.jpg", "$data_root/deleted.images/product.$code.$imgid.$thumb_size.jpg");
move("$www_root/images/products/$path/$imgid.$crop_size.jpg", "$data_root/deleted.images/product.$code.$imgid.$crop_size.jpg");

Expand Down

0 comments on commit abb1aff

Please sign in to comment.