Skip to content

Commit

Permalink
Configure to change timestamps explicitly only.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Jun 27, 2024
1 parent 5efbbf0 commit 0a1bdb6
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public Scheme getScheme() {

@Override
public DirectoryTimestamp getDirectoryTimestamp() {
return DirectoryTimestamp.implicit;
return DirectoryTimestamp.explicit;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,12 @@ public void testFindFile() throws Exception {
final Path folder = new BrickDirectoryFeature(session).mkdir(
new Path(new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
final long folderTimestamp = f.find(folder).getModificationDate();
final Path test = new BrickTouchFeature(session).touch(new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
assertEquals(Protocol.DirectoryTimestamp.implicit, session.getHost().getProtocol().getDirectoryTimestamp());
final Path test = new BrickTouchFeature(session).touch(new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)),
new TransferStatus().withModified(1719480508000L));
assertEquals(Protocol.DirectoryTimestamp.explicit, session.getHost().getProtocol().getDirectoryTimestamp());
assertNotEquals(folderTimestamp, f.find(folder).getModificationDate());
assertNotEquals(rootAttributes, f.find(root));
assertNotEquals(rootAttributes.getModificationDate(), f.find(root).getModificationDate());
assertEquals(rootAttributes, f.find(root));
assertEquals(rootAttributes.getModificationDate(), f.find(root).getModificationDate());
final PathAttributes attributes = f.find(test);
assertEquals(0L, attributes.getSize());
assertNotEquals(-1L, attributes.getModificationDate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ public class BrickProtocolTest {
@Test
public void testFeatures() {
assertEquals(Protocol.Case.insensitive, new BrickProtocol().getCaseSensitivity());
assertEquals(Protocol.DirectoryTimestamp.implicit, new BrickProtocol().getDirectoryTimestamp());
assertEquals(Protocol.DirectoryTimestamp.explicit, new BrickProtocol().getDirectoryTimestamp());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import ch.cyberduck.core.Path;
import ch.cyberduck.core.PathAttributes;
import ch.cyberduck.core.features.Delete;
import ch.cyberduck.core.features.Timestamp;
import ch.cyberduck.core.shared.DefaultAttributesFinderFeature;
import ch.cyberduck.core.shared.DefaultHomeFinderService;
import ch.cyberduck.core.transfer.TransferStatus;
Expand Down Expand Up @@ -58,4 +59,12 @@ public void testSetTimestampDirectory() throws Exception {
assertEquals(5000L, new DefaultAttributesFinderFeature(session).find(file).getModificationDate());
new BrickDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
}

@Test
public void testSetTimestampRoot() throws Exception {
final Path file = new Path("/", EnumSet.of(Path.Type.directory, Path.Type.volume));
final long ts = System.currentTimeMillis();
new BrickTimestampFeature(session).setTimestamp(file, ts);
assertEquals(Timestamp.toSeconds(ts), new BrickAttributesFinderFeature(session).find(file).getModificationDate());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void testWriteSinglePart() throws Exception {
assertNull(out.getStatus());
assertTrue(new BrickFindFeature(session).find(file));
final PathAttributes attributes = new BrickAttributesFinderFeature(session).find(file);
assertNotEquals(containerTimestamp, new BrickAttributesFinderFeature(session).find(container).getModificationDate());
assertEquals(containerTimestamp, new BrickAttributesFinderFeature(session).find(container).getModificationDate());
assertEquals(content.length, attributes.getSize());
final byte[] compare = new byte[content.length];
final InputStream stream = new BrickReadFeature(session).read(file, new TransferStatus().withLength(content.length), new DisabledConnectionCallback());
Expand Down

0 comments on commit 0a1bdb6

Please sign in to comment.