-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0fb1922
commit 691b6f3
Showing
14 changed files
with
70 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export { createDir } from './create-dir'; | ||
export { list } from './list'; | ||
export { moveFile } from './move-file'; | ||
export { removeDir } from './remove-dir'; | ||
export { removeFile } from './remove-file'; | ||
export { uploadFromLocal, uploadFromBytes } from './upload'; | ||
export { uploadFromBytes, uploadFromLocal } from './upload'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Client } from 'src/api'; | ||
import { FileOrDirectoryDoesNotExistError } from 'src/errors/path'; | ||
|
||
import { navigateToDir } from './navigate-to-dir'; | ||
import { splitPath } from './utils'; | ||
|
||
export const moveFile = | ||
(client: Client) => async (pathFrom: string, pathTo: string) => { | ||
const [dirFrom, nameFrom] = splitPath(pathFrom); | ||
const dir = navigateToDir(client)(dirFrom); | ||
const fileRef = dir.findFiles([nameFrom])[0]; | ||
|
||
if (!fileRef) { | ||
throw new FileOrDirectoryDoesNotExistError( | ||
pathFrom, | ||
`move file from ${pathFrom} to ${pathTo}`, | ||
); | ||
} | ||
|
||
const [dirTo, nameTo] = splitPath(pathTo); | ||
|
||
try { | ||
const dir2 = navigateToDir(client)(dirTo); | ||
dir2.createFileRef(nameTo, fileRef.getMessageId()); | ||
await client.deleteFile(fileRef); | ||
} catch (err) { | ||
throw new FileOrDirectoryDoesNotExistError( | ||
dirTo, | ||
`move file from ${pathFrom} to ${pathTo}`, | ||
); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters