Skip to content

Commit

Permalink
Merge pull request #14376 from iterate-ch/feature/MD-18872-versioning
Browse files Browse the repository at this point in the history
Keep previous version when overwriting file on upload
  • Loading branch information
dkocher authored Sep 23, 2023
2 parents 4f0207e + e8f47e3 commit a1eca69
Show file tree
Hide file tree
Showing 63 changed files with 714 additions and 257 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ public Comparator<String> getListComparator() {
return new DefaultLexicographicOrderComparator();
}

@Override
public VersioningMode getVersioningMode() {
return VersioningMode.storage;
}

@Override
@SuppressWarnings("unchecked")
public <T> T getFeature(final Class<T> type) {
Expand Down
5 changes: 5 additions & 0 deletions backblaze/src/main/java/ch/cyberduck/core/b2/B2Protocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ public Comparator<String> getListComparator() {
return new DefaultLexicographicOrderComparator();
}

@Override
public VersioningMode getVersioningMode() {
return VersioningMode.storage;
}

@Override
@SuppressWarnings("unchecked")
public <T> T getFeature(final Class<T> type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ public boolean isRevertable(final Path file) {

@Override
public AttributedList<Path> list(final Path file, final ListProgressListener listener) throws BackgroundException {
if(file.isDirectory()) {
return AttributedList.emptyList();
}
return new B2ObjectListService(session, fileid).list(file, listener).filter(new NullFilter<Path>() {
@Override
public boolean accept(final Path f) {
Expand Down
5 changes: 5 additions & 0 deletions box/src/main/java/ch/cyberduck/core/box/BoxProtocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ public DirectoryTimestamp getDirectoryTimestamp() {
return DirectoryTimestamp.explicit;
}

@Override
public VersioningMode getVersioningMode() {
return VersioningMode.storage;
}

@Override
public <T> T getFeature(final Class<T> type) {
if(type == ComparisonService.class) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ public boolean validate(final Credentials credentials, final LoginOptions option
return true;
}

@Override
public VersioningMode getVersioningMode() {
return VersioningMode.storage;
}

@Override
@SuppressWarnings("unchecked")
public <T> T getFeature(final Class<T> type) {
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/java/ch/cyberduck/core/AbstractProtocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ public Comparator<String> getListComparator() {
return new NullComparator<>();
}

@Override
public VersioningMode getVersioningMode() {
return VersioningMode.custom;
}

@Override
public Map<String, String> getProperties() {
return Collections.emptyMap();
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/java/ch/cyberduck/core/Profile.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ public Comparator<String> getListComparator() {
return parent.getListComparator();
}

@Override
public VersioningMode getVersioningMode() {
return parent.getVersioningMode();
}

@Override
public String getIdentifier() {
return parent.getIdentifier();
Expand Down
23 changes: 23 additions & 0 deletions core/src/main/java/ch/cyberduck/core/Protocol.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public interface Protocol extends Comparable<Protocol>, Serializable {
*/
Comparator<String> getListComparator();

VersioningMode getVersioningMode();

/**
* @return True if anonymous login is possible.
*/
Expand Down Expand Up @@ -352,6 +354,27 @@ enum Statefulness {
stateless
}

enum VersioningMode {
/**
* No versioning enabled when uploading files
*/
none {

},
/**
* Versioning is handled by storage implementation
*/
storage {

},
/**
* Custom implementation using directory to save previous versions
*/
custom {

};
}

@SuppressWarnings("unchecked")
<T> T getFeature(final Class<T> type);
}
17 changes: 13 additions & 4 deletions core/src/main/java/ch/cyberduck/core/Session.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import ch.cyberduck.core.features.Read;
import ch.cyberduck.core.features.Search;
import ch.cyberduck.core.features.Upload;
import ch.cyberduck.core.features.Versioning;
import ch.cyberduck.core.features.Write;
import ch.cyberduck.core.preferences.Preferences;
import ch.cyberduck.core.preferences.PreferencesFactory;
Expand All @@ -44,6 +45,7 @@
import ch.cyberduck.core.shared.DefaultSearchFeature;
import ch.cyberduck.core.shared.DefaultUploadFeature;
import ch.cyberduck.core.shared.DefaultUrlProvider;
import ch.cyberduck.core.shared.DefaultVersioningFeature;
import ch.cyberduck.core.shared.DelegatingHomeFeature;
import ch.cyberduck.core.shared.DisabledBulkFeature;
import ch.cyberduck.core.shared.DisabledMoveFeature;
Expand Down Expand Up @@ -99,7 +101,7 @@ public boolean alert(final ConnectionCallback callback) throws BackgroundExcepti
return false;
}
return preferences.getBoolean(
String.format("connection.unsecure.warning.%s", host.getProtocol().getScheme()));
String.format("connection.unsecure.warning.%s", host.getProtocol().getScheme()));
}

public Session<?> withListener(final TranscriptListener listener) {
Expand Down Expand Up @@ -310,9 +312,6 @@ public <T> T _getFeature(final Class<T> type) {
if(type == Download.class) {
return (T) new DefaultDownloadFeature(this.getFeature(Read.class));
}
if(type == Bulk.class) {
return (T) new DisabledBulkFeature();
}
if(type == Move.class) {
return (T) new DisabledMoveFeature();
}
Expand Down Expand Up @@ -340,6 +339,16 @@ public <T> T _getFeature(final Class<T> type) {
if(type == Home.class) {
return (T) new DelegatingHomeFeature(new WorkdirHomeFeature(host), new DefaultPathHomeFeature(host));
}
if(type == Versioning.class) {
return (T) new DefaultVersioningFeature(this);
}
if(type == Bulk.class) {
switch(host.getProtocol().getVersioningMode()) {
case custom:
return (T) new DefaultVersioningFeature(this);
}
return (T) new DisabledBulkFeature();
}
return host.getProtocol().getFeature(type);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import com.google.gson.internal.bind.util.ISO8601Utils;

public class RFC3339DateFormatter implements DateFormatter {
public class ISO8601DateFormatter implements DateFormatter {

@Override
public String format(final Date input, final TimeZone zone) {
Expand Down
204 changes: 0 additions & 204 deletions core/src/main/java/ch/cyberduck/core/date/ISO8601DateParser.java

This file was deleted.

Loading

0 comments on commit a1eca69

Please sign in to comment.