Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep previous version when overwriting file on upload #14376

Merged
merged 33 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e52f3fe
Define versioning support in protocols.
dkocher Mar 17, 2023
a56e9b9
Flag if versioning should be enabled in upload transfer.
dkocher Mar 17, 2023
8673767
Versioning feature to list and revert versions in pre-defined directo…
dkocher Mar 17, 2023
6032048
Merge date formatter implementations.
dkocher Mar 18, 2023
ff104f5
Filter by filename.
dkocher Mar 19, 2023
c158260
Bulk feature to delete previous versions given limit in preferences a…
dkocher Mar 20, 2023
8b0d876
Rewrite as regular upload filter.
dkocher Mar 24, 2023
2edee91
Check for existing file.
dkocher Mar 25, 2023
10ea790
Add check for filename pattern.
dkocher Mar 25, 2023
ba67b2f
Add check for support of rename operation.
dkocher Mar 25, 2023
f71d214
Allow custom date format.
dkocher Mar 28, 2023
4427452
Review include pattern.
dkocher Mar 29, 2023
d770d0d
Refactor moving logic to feature.
dkocher Mar 29, 2023
20c908e
Move files matching versioning criteria instead of delete.
dkocher Mar 29, 2023
b7128fa
Add check if versioned directory exists.
dkocher Mar 29, 2023
57acdd0
Allow listing versions for directory.
dkocher Mar 29, 2023
ebe17eb
Revert to upload option instead of filter.
dkocher Mar 29, 2023
f940619
Allow restoring directories.
dkocher Mar 29, 2023
8ec20d9
Allow revert when inside versioning directory.
dkocher Mar 29, 2023
97e2484
Generify filename patterns.
dkocher Mar 29, 2023
e40d0de
Merge implementations into single class and review protocol support.
dkocher Mar 30, 2023
573116d
Fix revert support.
dkocher Mar 30, 2023
f5dd309
Cleanup of previous folders not supported when delete feature is not …
dkocher Mar 30, 2023
dd76c65
Remove redundant check.
dkocher Mar 30, 2023
e936178
No versioning for previous versions it-selves.
dkocher Mar 30, 2023
459749e
Extract method to check for support.
dkocher Mar 30, 2023
31e8bca
Move previous versions along with rename.
dkocher Mar 30, 2023
ded1d62
Add enabled check.
dkocher Apr 2, 2023
90aae53
Review.
dkocher Apr 2, 2023
af2ade8
Check preferences.
dkocher Apr 2, 2023
808d18d
Fix tests.
dkocher Apr 2, 2023
2746b89
Make interface public.
dkocher Sep 6, 2023
e8f47e3
Do not apply versioning when resuming upload.
dkocher Sep 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 @@ -351,6 +353,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