From 7b268c41693a87d3d7485bb9758e39e1342afab8 Mon Sep 17 00:00:00 2001 From: dkocher Date: Wed, 14 Oct 2015 09:05:33 +0000 Subject: [PATCH] Always compare by size to catch zero byte files. Fix #8657. git-svn-id: https://svn.cyberduck.io/trunk@18330 9e2dff1d-8f06-0410-b5b1-4d70b6340adc --- source/ch/cyberduck/core/preferences/Preferences.java | 3 --- .../core/synchronization/ComparisonServiceFilter.java | 19 +++++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/source/ch/cyberduck/core/preferences/Preferences.java b/source/ch/cyberduck/core/preferences/Preferences.java index c8443c4a83..4e04018e5e 100644 --- a/source/ch/cyberduck/core/preferences/Preferences.java +++ b/source/ch/cyberduck/core/preferences/Preferences.java @@ -510,9 +510,6 @@ public abstract class Preferences { */ defaults.put("queue.download.complete.open", String.valueOf(false)); - defaults.put("queue.sync.compare.hash", String.valueOf(true)); - defaults.put("queue.sync.compare.size", String.valueOf(false)); - defaults.put("queue.dock.badge", String.valueOf(false)); defaults.put("queue.sleep.prevent", String.valueOf(true)); diff --git a/source/ch/cyberduck/core/synchronization/ComparisonServiceFilter.java b/source/ch/cyberduck/core/synchronization/ComparisonServiceFilter.java index a7610f6538..2b11153ba3 100644 --- a/source/ch/cyberduck/core/synchronization/ComparisonServiceFilter.java +++ b/source/ch/cyberduck/core/synchronization/ComparisonServiceFilter.java @@ -29,7 +29,6 @@ import ch.cyberduck.core.exception.BackgroundException; import ch.cyberduck.core.features.Attributes; import ch.cyberduck.core.features.Find; import ch.cyberduck.core.io.ChecksumComputeFactory; -import ch.cyberduck.core.preferences.PreferencesFactory; import ch.cyberduck.core.shared.DefaultAttributesFeature; import ch.cyberduck.core.shared.DefaultFindFeature; @@ -87,7 +86,7 @@ public class ComparisonServiceFilter implements ComparePathFilter { return Comparison.equal; } final PathAttributes attributes = attribute.find(file); - if(PreferencesFactory.get().getBoolean("queue.sync.compare.hash")) { + { // MD5/ETag Checksum is supported if(attributes.getChecksum() != null) { progress.message(MessageFormat.format( @@ -101,18 +100,22 @@ public class ComparisonServiceFilter implements ComparePathFilter { } } } - if(PreferencesFactory.get().getBoolean("queue.sync.compare.size")) { + // We must always compare the size because the download filter will have already created a temporary 0 byte file + { final Comparison comparison = size.compare(attributes, local.attributes()); if(!Comparison.notequal.equals(comparison)) { - // Decision is available + // Decision is available. Equal local or remote. return comparison; } + // Continue to decide with timestamp when both files exist and are not zero bytes } // Default comparison is using timestamp of file. - final Comparison comparison = timestamp.compare(attributes, local.attributes()); - if(!Comparison.notequal.equals(comparison)) { - // Decision is available - return comparison; + { + final Comparison comparison = timestamp.compare(attributes, local.attributes()); + if(!Comparison.notequal.equals(comparison)) { + // Decision is available + return comparison; + } } } else { -- 2.11.4.GIT