Skip to content

Commit

Permalink
Review.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkocher committed Apr 27, 2019
1 parent 841ac91 commit b19f762
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* [email protected]
*/

import ch.cyberduck.core.AbstractPath;
import ch.cyberduck.core.DisabledConnectionCallback;
import ch.cyberduck.core.Path;
import ch.cyberduck.core.PathAttributes;
Expand Down Expand Up @@ -72,7 +71,7 @@ public Path mkdir(final Path folder, final String region, final TransferStatus s
if(Checksum.NONE == status.getChecksum()) {
status.setChecksum(writer.checksum(folder).compute(new NullInputStream(0L), status));
}
final EnumSet<AbstractPath.Type> type = EnumSet.copyOf(folder.getType());
final EnumSet<Path.Type> type = EnumSet.copyOf(folder.getType());
type.add(Path.Type.placeholder);
final Path placeholder = new Path(folder.getParent(), folder.getName(), type,
new PathAttributes(folder.attributes()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* [email protected]
*/

import ch.cyberduck.core.AbstractPath;
import ch.cyberduck.core.AttributedList;
import ch.cyberduck.core.Cache;
import ch.cyberduck.core.ListProgressListener;
Expand Down Expand Up @@ -100,7 +99,7 @@ public AttributedList<Path> list(final Path directory, final ListProgressListene
}
}
// A directory is designated by a delimiter character.
final EnumSet<AbstractPath.Type> types = object instanceof CloudBlobDirectory
final EnumSet<Path.Type> types = object instanceof CloudBlobDirectory
? EnumSet.of(Path.Type.directory, Path.Type.placeholder) : EnumSet.of(Path.Type.file);
final Path child = new Path(directory, PathNormalizer.name(object.getUri().getPath()), types, attributes);
children.add(child);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* GNU General Public License for more details.
*/

import ch.cyberduck.core.AbstractPath;
import ch.cyberduck.core.Acl;
import ch.cyberduck.core.DefaultIOExceptionMappingService;
import ch.cyberduck.core.DisabledConnectionCallback;
Expand Down Expand Up @@ -83,7 +82,7 @@ public Path mkdir(final Path folder, final String region, final TransferStatus s
status.setMime(MimeTypeService.DEFAULT_CONTENT_TYPE);
final StatusOutputStream<BaseB2Response> out = writer.write(folder, status, new DisabledConnectionCallback());
new DefaultStreamCloser().close(out);
final EnumSet<AbstractPath.Type> type = EnumSet.copyOf(folder.getType());
final EnumSet<Path.Type> type = EnumSet.copyOf(folder.getType());
type.add(Path.Type.placeholder);
return new Path(folder.getParent(), folder.getName(), type,
new B2AttributesFinderFeature(session, fileid).toAttributes((B2FileResponse) out.getStatus()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,20 @@
* GNU General Public License for more details.
*/

import ch.cyberduck.core.*;
import ch.cyberduck.core.Credentials;
import ch.cyberduck.core.DescriptiveUrl;
import ch.cyberduck.core.Host;
import ch.cyberduck.core.ListService;
import ch.cyberduck.core.LocaleFactory;
import ch.cyberduck.core.LoginOptions;
import ch.cyberduck.core.PasswordCallback;
import ch.cyberduck.core.PasswordStore;
import ch.cyberduck.core.Path;
import ch.cyberduck.core.PathAttributes;
import ch.cyberduck.core.Permission;
import ch.cyberduck.core.Session;
import ch.cyberduck.core.SimplePathPredicate;
import ch.cyberduck.core.UrlProvider;
import ch.cyberduck.core.cryptomator.features.*;
import ch.cyberduck.core.cryptomator.impl.CryptoDirectoryProvider;
import ch.cyberduck.core.cryptomator.impl.CryptoFilenameProvider;
Expand Down Expand Up @@ -92,7 +105,7 @@ public CryptoVault(final Path home, final String masterkey, final byte[] pepper)
this.masterkey = new Path(home, masterkey, EnumSet.of(Path.Type.file, Path.Type.vault));
this.pepper = pepper;
// New vault home with vault flag set for internal use
final EnumSet<AbstractPath.Type> type = EnumSet.copyOf(home.getType());
final EnumSet<Path.Type> type = EnumSet.copyOf(home.getType());
type.add(Path.Type.vault);
final Path vault = new Path(home.getAbsolute(), type, new PathAttributes(home.attributes()));
this.filenameProvider = new CryptoFilenameProvider(vault);
Expand Down Expand Up @@ -350,7 +363,7 @@ public Path encrypt(final Session<?> session, final Path file, final String dire
}
// Translate file size
attributes.setSize(this.toCiphertextSize(file.attributes().getSize()));
final EnumSet<AbstractPath.Type> type = EnumSet.copyOf(file.getType());
final EnumSet<Path.Type> type = EnumSet.copyOf(file.getType());
type.remove(Path.Type.directory);
type.remove(Path.Type.decrypted);
type.add(Path.Type.file);
Expand Down Expand Up @@ -410,7 +423,7 @@ public Path decrypt(final Session<?> session, final Path file) throws Background
attributes.setEncrypted(file);
// Add reference for vault
attributes.setVault(home);
final EnumSet<AbstractPath.Type> type = EnumSet.copyOf(file.getType());
final EnumSet<Path.Type> type = EnumSet.copyOf(file.getType());
type.remove(inflated.getName().startsWith(DIR_PREFIX) ? Path.Type.file : Path.Type.directory);
type.add(inflated.getName().startsWith(DIR_PREFIX) ? Path.Type.directory : Path.Type.file);
type.remove(Path.Type.encrypted);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* GNU General Public License for more details.
*/

import ch.cyberduck.core.AbstractPath;
import ch.cyberduck.core.CacheReference;
import ch.cyberduck.core.DefaultPathPredicate;
import ch.cyberduck.core.Path;
Expand Down Expand Up @@ -68,7 +67,7 @@ public CryptoDirectoryProvider(final Path vault, final CryptoVault cryptomator)
* @param type File type
* @return Encrypted filename
*/
public String toEncrypted(final Session<?> session, final String directoryId, final String filename, final EnumSet<AbstractPath.Type> type) throws BackgroundException {
public String toEncrypted(final Session<?> session, final String directoryId, final String filename, final EnumSet<Path.Type> type) throws BackgroundException {
final String prefix = type.contains(Path.Type.directory) ? CryptoVault.DIR_PREFIX : "";
final String ciphertextName = String.format("%s%s", prefix,
cryptomator.getCryptor().fileNameCryptor().encryptFilename(filename, directoryId.getBytes(StandardCharsets.UTF_8)));
Expand Down Expand Up @@ -106,7 +105,7 @@ public Path toEncrypted(final Session<?> session, final String directoryId, fina
// Intermediate directory
final Path intermediate = new Path(dataRoot, directoryIdHash.substring(0, 2), dataRoot.getType());
// Add encrypted type
final EnumSet<AbstractPath.Type> type = EnumSet.copyOf(directory.getType());
final EnumSet<Path.Type> type = EnumSet.copyOf(directory.getType());
type.add(Path.Type.encrypted);
type.remove(Path.Type.decrypted);
return new Path(intermediate, directoryIdHash.substring(2), type, attributes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/


import ch.cyberduck.core.AbstractPath;
import ch.cyberduck.core.AttributedList;
import ch.cyberduck.core.Cache;
import ch.cyberduck.core.DisabledListProgressListener;
Expand Down Expand Up @@ -62,7 +61,7 @@ public AttributedList<Path> list(final Path directory, final ListProgressListene
null, null, "name:asc", offset, chunksize, StringUtils.EMPTY, null);
for(Node node : nodes.getItems()) {
final PathAttributes attributes = feature.toAttributes(node);
final EnumSet<AbstractPath.Type> type = feature.toType(node);
final EnumSet<Path.Type> type = feature.toType(node);
final Path file = new Path(directory, node.getName(), type, attributes);
children.add(file);
listener.chunk(directory, children);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* GNU General Public License for more details.
*/

import ch.cyberduck.core.AbstractPath;
import ch.cyberduck.core.AttributedList;
import ch.cyberduck.core.Cache;
import ch.cyberduck.core.Filter;
Expand Down Expand Up @@ -54,7 +53,7 @@ public AttributedList<Path> search(final Path workdir, final Filter<Path> regex,
final SDSAttributesFinderFeature feature = new SDSAttributesFinderFeature(session, nodeid);
for(Node node : list.getItems()) {
final PathAttributes attributes = feature.toAttributes(node);
final EnumSet<AbstractPath.Type> type;
final EnumSet<Path.Type> type;
switch(node.getType()) {
case ROOM:
type = EnumSet.of(Path.Type.directory, Path.Type.volume);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* GNU General Public License for more details.
*/

import ch.cyberduck.core.AbstractPath;
import ch.cyberduck.core.AttributedList;
import ch.cyberduck.core.Cache;
import ch.cyberduck.core.ListProgressListener;
Expand Down Expand Up @@ -85,7 +84,7 @@ private void parse(final Path directory, final ListProgressListener listener, fi
}

protected Path parse(final Path directory, final Metadata metadata) {
final EnumSet<AbstractPath.Type> type;
final EnumSet<Path.Type> type;
if(metadata instanceof FileMetadata) {
type = EnumSet.of(Path.Type.file);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* GNU General Public License for more details.
*/

import ch.cyberduck.core.AbstractPath;
import ch.cyberduck.core.AttributedList;
import ch.cyberduck.core.Cache;
import ch.cyberduck.core.Filter;
Expand Down Expand Up @@ -62,7 +61,7 @@ public AttributedList<Path> search(final Path workdir, final Filter<Path> regex,
final List<SearchMatch> matches = result.getMatches();
for(SearchMatch match : matches) {
final Metadata metadata = match.getMetadata();
final EnumSet<AbstractPath.Type> type;
final EnumSet<Path.Type> type;
if(metadata instanceof FileMetadata) {
type = EnumSet.of(Path.Type.file);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public AttributedList<Path> read(final Path directory, final List<String> replie
final String target = f.getLink();
if(StringUtils.isBlank(target)) {
log.warn(String.format("Missing symbolic link target for %s", parsed));
final EnumSet<AbstractPath.Type> type = parsed.getType();
final EnumSet<Path.Type> type = parsed.getType();
type.remove(AbstractPath.Type.symboliclink);
}
else if(StringUtils.startsWith(target, String.valueOf(Path.DELIMITER))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* GNU General Public License for more details.
*/

import ch.cyberduck.core.AbstractPath;
import ch.cyberduck.core.AttributedList;
import ch.cyberduck.core.Cache;
import ch.cyberduck.core.ListProgressListener;
Expand Down Expand Up @@ -102,7 +101,7 @@ public AttributedList<Path> list(final Path directory, final ListProgressListene
continue;
}
// Use placeholder type to mark Google Apps document to download as web link file
final EnumSet<AbstractPath.Type> type = DRIVE_FOLDER.equals(f.getMimeType()) ? EnumSet.of(Path.Type.directory) :
final EnumSet<Path.Type> type = DRIVE_FOLDER.equals(f.getMimeType()) ? EnumSet.of(Path.Type.directory) :
StringUtils.startsWith(f.getMimeType(), GOOGLE_APPS_PREFIX)
? EnumSet.of(Path.Type.file, Path.Type.placeholder) : EnumSet.of(Path.Type.file);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
@Category(IntegrationTest.class)
public class MantaSearchFeatureTest extends AbstractMantaTest {

private static final EnumSet<AbstractPath.Type> TYPE_DIRECTORY = EnumSet.of(AbstractPath.Type.directory);
private static final EnumSet<AbstractPath.Type> TYPE_FILE = EnumSet.of(AbstractPath.Type.file);
private static final EnumSet<Path.Type> TYPE_DIRECTORY = EnumSet.of(AbstractPath.Type.directory);
private static final EnumSet<Path.Type> TYPE_FILE = EnumSet.of(AbstractPath.Type.file);

@Test
public void testSearchFileNotFound() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* [email protected]
*/

import ch.cyberduck.core.AbstractPath;
import ch.cyberduck.core.AttributedList;
import ch.cyberduck.core.Cache;
import ch.cyberduck.core.DefaultIOExceptionMappingService;
Expand Down Expand Up @@ -77,7 +76,7 @@ public AttributedList<Path> list(final Path directory, final ListProgressListene
null, limit, marker, Path.DELIMITER);
for(StorageObject object : list) {
final PathAttributes attr = attributes.toAttributes(object);
final EnumSet<AbstractPath.Type> types = "application/directory"
final EnumSet<Path.Type> types = "application/directory"
.equals(object.getMimeType()) ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file);
if(StringUtils.endsWith(object.getName(), String.valueOf(Path.DELIMITER))) {
if(children.contains(new Path(directory, PathNormalizer.name(object.getName()), EnumSet.of(Path.Type.directory), attr))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* Bug fixes, suggestions and comments should be sent to [email protected]
*/

import ch.cyberduck.core.AbstractPath;
import ch.cyberduck.core.DisabledConnectionCallback;
import ch.cyberduck.core.Path;
import ch.cyberduck.core.PathAttributes;
Expand Down Expand Up @@ -67,7 +66,7 @@ public Path mkdir(final Path folder, final String region, final TransferStatus s
}
// Add placeholder object
status.setMime(MIMETYPE);
final EnumSet<AbstractPath.Type> type = EnumSet.copyOf(folder.getType());
final EnumSet<Path.Type> type = EnumSet.copyOf(folder.getType());
type.add(Path.Type.placeholder);
final StatusOutputStream<StorageObject> out = writer.write(new Path(folder.getParent(), folder.getName(), type,
new PathAttributes(folder.attributes())), status, new DisabledConnectionCallback());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* [email protected]
*/

import ch.cyberduck.core.AbstractPath;
import ch.cyberduck.core.AttributedList;
import ch.cyberduck.core.Cache;
import ch.cyberduck.core.ListProgressListener;
Expand Down Expand Up @@ -100,7 +99,7 @@ public AttributedList<Path> list(final Path directory, final ListProgressListene
hasDirectoryPlaceholder = true;
continue;
}
final EnumSet<AbstractPath.Type> types = object.getKey().endsWith(String.valueOf(Path.DELIMITER))
final EnumSet<Path.Type> types = object.getKey().endsWith(String.valueOf(Path.DELIMITER))
? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file);
final Path file;
final PathAttributes attr = attributes.toAttributes(object);
Expand Down

0 comments on commit b19f762

Please sign in to comment.