Skip to content

Commit

Permalink
subs: try to get select subs to work on smb but after fix still getti…
Browse files Browse the repository at this point in the history
…ng exception in rename
  • Loading branch information
courville committed Jun 16, 2024
1 parent 8365c02 commit df696e1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/com/archos/filecorelibrary/jcifs/JcifsFileEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public boolean rename(String newName) {
try {
SmbFile from = getSmbFile(mUri).smbFile;
if (from != null) {
SmbFile to = getSmbFile(Uri.parse(from.getParent() + "/" + newName)).smbFile;
SmbFile to = getSmbFile(Uri.parse(from.getParent() + newName)).smbFile;
log.debug("rename: " + from + " to " + to);
if (to != null) {
from.renameTo(to);
return true;
Expand Down
10 changes: 8 additions & 2 deletions src/com/archos/filecorelibrary/smbj/SmbjFileEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,15 @@ public Boolean delete() throws Exception {
public boolean rename(String newName) {
String mFilePath = getFilePath(mUri);
try {
File from = SmbjUtils.peekInstance().getSmbShare(mUri).openFile(mFilePath, EnumSet.of(AccessMask.GENERIC_ALL), null, SMB2ShareAccess.ALL, SMB2CreateDisposition.FILE_OPEN, null);
File from = SmbjUtils.peekInstance().getSmbShare(mUri).openFile(mFilePath,
EnumSet.of(AccessMask.FILE_READ_DATA),
EnumSet.of(FileAttributes.FILE_ATTRIBUTE_READONLY),
EnumSet.of(SMB2ShareAccess.FILE_SHARE_READ),
SMB2CreateDisposition.FILE_OPEN,
EnumSet.of(SMB2CreateOptions.FILE_RANDOM_ACCESS));
log.debug("rename: mFilePath=" + mFilePath + " -> " + getParentDirectoryPath(mFilePath) + newName);
if (from != null) {
from.rename(getParentDirectoryPath(mFilePath) + "/" + newName);
from.rename(getParentDirectoryPath(mFilePath) + newName);
return true;
}
} catch (IOException e) {
Expand Down
2 changes: 1 addition & 1 deletion src/com/archos/filecorelibrary/sshj/SshjFileEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public boolean rename(String newName) {
try {
final String mFilePath = getSftpPath(mUri);
final SFTPClient sftpClient = SshjUtils.peekInstance().getSFTPClient(mUri);
sftpClient.rename(getSftpPath(mUri), getParentDirectoryPath(mFilePath) + "/" + newName);
sftpClient.rename(getSftpPath(mUri), getParentDirectoryPath(mFilePath) + newName);
return true;
} catch (IOException e) {
caughtException(e, "SshjFileEditor:rename", "IOException" + mUri);
Expand Down

0 comments on commit df696e1

Please sign in to comment.