Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/1.1.14'
Browse files Browse the repository at this point in the history
  • Loading branch information
Armin Schrenk committed Apr 28, 2020
2 parents 77c350a + bb0e4d0 commit 488b3a5
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.cryptomator</groupId>
<artifactId>dokany-nio-adapter</artifactId>
<version>1.1.13</version>
<version>1.1.14</version>
<description>Access resources at a given NIO path via Dokany.</description>
<name>Dokany-NIO Adapter</name>
<url>https://github.com/cryptomator/dokany-nio-adapter</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.nio.file.DirectoryStream;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.FileStore;
import java.nio.file.FileSystemException;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.LinkOption;
Expand Down Expand Up @@ -150,6 +151,16 @@ private int createDirectory(Path path, CreationDisposition creationDisposition,
LOG.trace("Directory {} already exists.", path);
return Win32ErrorCode.ERROR_ALREADY_EXISTS.getMask();
}
} catch (FileSystemException e) {
final String reason = e.getReason().toLowerCase();
if (reason.contains("path too long") || reason.contains("extension too long") || reason.contains("path too long")) {
LOG.warn("zwCreateFile(): Creation of {} failed, file name too long.", path);
return Win32ErrorCode.ERROR_FILENAME_EXCED_RANGE.getMask();
} else {
LOG.debug("zwCreateFile(): IO error occured during the creation of {}.", path);
LOG.debug("zwCreateFile(): ", e);
return Win32ErrorCode.ERROR_CANNOT_MAKE.getMask();
}
} catch (IOException e) {
//we dont know what the hell happened
LOG.debug("zwCreateFile(): IO error occured during the creation of {}.", path);
Expand Down Expand Up @@ -182,6 +193,7 @@ private int createDirectory(Path path, CreationDisposition creationDisposition,
}
}


private int createFile(Path path, CreationDisposition creationDisposition, Set<OpenOption> openOptions, int rawFileAttributes, DokanyFileInfo dokanyFileInfo) {
LOG.trace("Try to open {} as File.", path);
final int mask = creationDisposition.getMask();
Expand Down Expand Up @@ -240,6 +252,16 @@ else if ((attr != null && attr.isReadOnly() || ((rawFileAttributes & FileAttribu
LOG.trace("zwCreateFile(): Access to file {} was denied.", path);
LOG.trace("Cause:", e);
return Win32ErrorCode.ERROR_ACCESS_DENIED.getMask();
} catch (FileSystemException e) {
final String reason = e.getReason().toLowerCase();
if (reason.contains("path too long") || reason.contains("extension too long") || reason.contains("path too long")) {
LOG.warn("zwCreateFile(): Creation of {} failed, file name too long.", path);
return Win32ErrorCode.ERROR_FILENAME_EXCED_RANGE.getMask();
} else {
LOG.debug("zwCreateFile(): IO error occured during the creation of {}.", path);
LOG.debug("zwCreateFile(): ", e);
return Win32ErrorCode.ERROR_CANNOT_MAKE.getMask();
}
} catch (IOException e) {
if (attr != null) {
LOG.debug("zwCreateFile(): IO error occurred during opening handle to {}.", path);
Expand Down Expand Up @@ -772,13 +794,23 @@ public int moveFile(WString rawPath, WString rawNewFileName, boolean rawReplaceI
LOG.trace("({}) Successful moved resource {} to {}.", dokanyFileInfo.Context, path, newPath);
return Win32ErrorCode.ERROR_SUCCESS.getMask();
} catch (FileAlreadyExistsException e) {
LOG.trace("({}) Ressource {} already exists at {}.", dokanyFileInfo.Context, path, newPath);
LOG.trace("({}) Resource {} already exists at {}.", dokanyFileInfo.Context, path, newPath);
return Win32ErrorCode.ERROR_FILE_EXISTS.getMask();
} catch (DirectoryNotEmptyException e) {
LOG.trace("({}) Target directoy {} is not emtpy.", dokanyFileInfo.Context, path);
LOG.trace("({}) Target directory {} is not emtpy.", dokanyFileInfo.Context, path);
return Win32ErrorCode.ERROR_DIR_NOT_EMPTY.getMask();
} catch (FileSystemException e) {
final String reason = e.getReason().toLowerCase();
if (reason.contains("path too long") || reason.contains("extension too long") || reason.contains("path too long")) {
LOG.warn("({}) Moving resource {} failed, file name too long.", dokanyFileInfo.Context, path);
return Win32ErrorCode.ERROR_FILENAME_EXCED_RANGE.getMask();
} else {
LOG.debug("({}) moveFile(): IO error while moving resource {}.", dokanyFileInfo.Context, path);
LOG.debug("moveFile(): ", e);
return Win32ErrorCode.ERROR_GEN_FAILURE.getMask();
}
} catch (IOException e) {
LOG.debug("({}) moveFile(): IO error occured while moving ressource {}.", dokanyFileInfo.Context, path);
LOG.debug("({}) moveFile(): IO error while moving resource {}.", dokanyFileInfo.Context, path);
LOG.debug("moveFile(): ", e);
return Win32ErrorCode.ERROR_GEN_FAILURE.getMask();
}
Expand Down Expand Up @@ -935,5 +967,4 @@ private Path getRootedPath(WString rawPath) {
assert root.isAbsolute();
return root.resolve(relativeUnixPath);
}

}

0 comments on commit 488b3a5

Please sign in to comment.