Skip to content

Commit 6c97e8f

Browse files
committed
add downsync flag to prevent setting a dynamic folder when downloading an asset on upgrade
1 parent 09f448e commit 6c97e8f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ public function prepare_upload( $post, $down_sync = false ) {
357357
// First check if this has a file and it can be uploaded.
358358
$file = get_attached_file( $post->ID );
359359
$file_size = 0;
360+
$downsync = false;
360361
if ( empty( $file ) ) {
361362
return new \WP_Error( 'attachment_no_file', __( 'Attachment did not have a file.', 'cloudinary' ) );
362363
} elseif ( ! file_exists( $file ) ) {
@@ -373,6 +374,7 @@ public function prepare_upload( $post, $down_sync = false ) {
373374
}
374375
$file = get_attached_file( $post->ID );
375376
$file_size = filesize( $file );
377+
$downsync = true;
376378
}
377379
}
378380
} else {
@@ -414,7 +416,7 @@ public function prepare_upload( $post, $down_sync = false ) {
414416
}
415417
// Check if this asset is a folder sync.
416418
$folder_sync = $media->get_post_meta( $post->ID, Sync::META_KEYS['folder_sync'], true );
417-
if ( ! empty( $folder_sync ) ) {
419+
if ( ! empty( $folder_sync ) && false === $downsync ) {
418420
$public_id_folder = $cld_folder; // Ensure the public ID folder is constant.
419421
} else {
420422
// Not folder synced, so set the folder to the folder that the asset originally came from.

0 commit comments

Comments
 (0)