Skip to content

Commit 0b50c15

Browse files
authored
Merge pull request #141 from cloudinary/hotfix/downsync
Hotfix downsync
2 parents 0241795 + 7e3e291 commit 0b50c15

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-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
@@ -404,6 +404,7 @@ public function prepare_upload( $post, $push_sync = false ) {
404404
if ( true === $push_sync ) {
405405
$download = $this->sync->managers['download']->down_sync( $post->ID );
406406
if ( is_wp_error( $download ) ) {
407+
delete_post_meta( $post->ID, Sync::META_KEYS['downloading'] );
407408
update_post_meta( $post->ID, Sync::META_KEYS['sync_error'], $download->get_error_message() );
408409

409410
return new \WP_Error( 'attachment_download_error', $download->get_error_message() );
@@ -541,7 +542,7 @@ public function prepare_upload( $post, $push_sync = false ) {
541542
$suffix_data = wp_parse_args( $suffix_meta, $suffix_defaults );
542543

543544
// Prepare a uniqueness check and get a suffix if needed.
544-
if ( true === $push_sync ) {
545+
if ( true === $push_sync && true !== $downsync ) {
545546
if ( $public_id !== $suffix_data['public_id'] || empty( $suffix_data['suffix'] ) ) {
546547
$suffix_data['suffix'] = $this->sync->add_suffix_maybe( $public_id, $post->ID );
547548
if ( ! empty( $suffix_data['suffix'] ) ) {
@@ -681,6 +682,7 @@ public function push_attachments( $attachments ) {
681682
$error = $result->get_error_message();
682683
$stats['fail'][] = $error;
683684
$this->media->update_post_meta( $attachment->ID, Sync::META_KEYS['sync_error'], $error );
685+
delete_post_meta( $attachment->ID, Sync::META_KEYS['syncing'] );
684686
continue;
685687
}
686688

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ public function mark( $id, $type = 'done' ) {
140140
$queue[ $type ][] = '<div>' . basename( $file ) . ': ' . $state->get_error_message() . '</div>';
141141
// Add a flag that this file had an error as to not try process it again.
142142
update_post_meta( $id, Sync::META_KEYS['sync_error'], $state->get_error_message() );
143+
delete_post_meta( $id, Sync::META_KEYS['syncing'], $state->get_error_message() );
143144
}
144145
} else {
145146
if ( ! in_array( $id, $queue[ $type ], true ) ) {

0 commit comments

Comments
 (0)