diff --git a/php/class-sync.php b/php/class-sync.php index 8af86dc77..31a66b978 100644 --- a/php/class-sync.php +++ b/php/class-sync.php @@ -270,7 +270,7 @@ public function can_sync( $attachment_id, $type = 'file' ) { public function get_sync_version( $attachment_id ) { $version = $this->managers['media']->get_post_meta( $attachment_id, self::META_KEYS['plugin_version'], true ); - return $version !== $this->plugin->version; + return $version . '-' . $this->plugin->version; } /** diff --git a/php/media/class-upgrade.php b/php/media/class-upgrade.php index 024b5ad46..19f3f23dc 100644 --- a/php/media/class-upgrade.php +++ b/php/media/class-upgrade.php @@ -107,6 +107,16 @@ public function convert_cloudinary_version( $attachment_id ) { } else { // v2 upgrade. $public_id = $this->media->get_public_id( $attachment_id, true ); + $suffix = $this->media->get_post_meta( $attachment_id, Sync::META_KEYS['suffix'], true ); + if ( ! empty( $suffix ) ) { + // Has suffix. Get delete and cleanup public ID. + if ( false !== strpos( $public_id, $suffix ) ) { + $public_id = str_replace( $suffix, '', $public_id ); + } + $public_id .= $suffix; + $this->media->delete_post_meta( $attachment_id, Sync::META_KEYS['suffix'] ); + update_post_meta( $attachment_id, Sync::META_KEYS['public_id'], $public_id ); + } // Check folder sync in order. if ( $this->media->is_folder_synced( $attachment_id ) ) { $public_id_folder = ltrim( dirname( $this->media->get_public_id( $attachment_id ) ) ); diff --git a/php/sync/class-push-sync.php b/php/sync/class-push-sync.php index b35257844..979581c6b 100644 --- a/php/sync/class-push-sync.php +++ b/php/sync/class-push-sync.php @@ -215,6 +215,11 @@ public function process_assets( $attachments = array() ) { } $stat[ $attachment_id ][ $type ] = $this->sync->run_sync_method( $type, 'sync', $attachment_id ); } + $prev_stat = $this->media->get_post_meta( $attachment_id, Sync::META_KEYS['process_log'], true ); + if ( empty( $prev_stat ) ) { + $prev_stat = array(); + } + $stat[ $attachment_id ] = array_merge( $prev_stat, $stat ); // remove pending. delete_post_meta( $attachment_id, Sync::META_KEYS['pending'] ); // Record Process log.