feat(core): Enhanced directory handling and file restoration from trash

This commit is contained in:
2024-11-24 19:56:12 +01:00
parent 8e9041fbbf
commit 154854dc21
5 changed files with 81 additions and 10 deletions

View File

@ -30,7 +30,7 @@ tap.test('should clean all contents', async () => {
tap.test('should delete a file into the normally', async () => {
const path = 'trashtest/trashme.txt';
const file = await myBucket.fastPut({
const file = await myBucket.fastPutStrict({
path,
contents: 'I\'m in the trash test content!',
});
@ -44,7 +44,7 @@ tap.test('should delete a file into the normally', async () => {
tap.test('should put a file into the trash', async () => {
const path = 'trashtest/trashme.txt';
const file = await myBucket.fastPut({
const file = await myBucket.fastPutStrict({
path,
contents: 'I\'m in the trash test content!',
});
@ -60,4 +60,19 @@ tap.test('should put a file into the trash', async () => {
});
});
tap.test('should restore a file from trash', async () => {
const baseDirectory = await myBucket.getBaseDirectory();
const file = await baseDirectory.getFileStrict({
path: 'trashtest/trashme.txt',
getFromTrash: true
});
const trashFileMeta = await file.getMetaData();
const data = await trashFileMeta.getCustomMetaData({
key: 'recycle'
});
expect(file).toBeInstanceOf(smartbucket.File);
await file.restore();
});
export default tap.start();