Skip to content

Commit 9994ee3

Browse files
committed
refactor copy objects request
1 parent 36183ca commit 9994ee3

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

src/contents.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,13 +663,26 @@ export class Drive implements Contents.IDrive {
663663
toDrive.name
664664
);
665665

666-
data = await copyObjects(currentDrive.name, {
666+
const result = await copyObjects(currentDrive.name, {
667667
path: relativePath,
668668
toPath: toRelativePath,
669669
newFileName: newFileName,
670670
toDrive: toDrive.name,
671671
registeredFileTypes: this._registeredFileTypes
672672
});
673+
674+
data = {
675+
name: newFileName,
676+
path: PathExt.join(currentDrive.name, result.formattedNewPath!),
677+
last_modified: result.response!.data.last_modified,
678+
created: '',
679+
content: PathExt.extname(newFileName) !== '' ? null : [], // TODO: add dir check
680+
format: result.format! as Contents.FileFormat,
681+
mimetype: result.mimetype!,
682+
size: result.response!.data.size,
683+
writable: true,
684+
type: result.type!
685+
};
673686
} else {
674687
// create new element at root would mean modifying a drive
675688
console.warn('Operation not supported.');

src/requests.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -408,23 +408,18 @@ export async function copyObjects(
408408
options.path,
409409
formattedNewPath
410410
);
411-
data = {
412-
name: options.newFileName,
413-
path: PathExt.join(options.toDrive, formattedNewPath),
414-
last_modified: copiedObject.data.last_modified,
415-
created: '',
416-
content: PathExt.extname(options.newFileName) !== '' ? null : [], // TODO: add dir check
411+
return {
412+
response: copiedObject,
413+
formattedNewPath: formattedNewPath,
417414
format: fileFormat as Contents.FileFormat,
418415
mimetype: fileMimeType,
419-
size: copiedObject.data.size,
420-
writable: true,
421416
type: fileType
422417
};
423418
} catch (error) {
424419
// copied failed if directory didn't exist and was only part of a path
425420
}
426421

427-
return data;
422+
return {};
428423
}
429424

430425
/**

0 commit comments

Comments
 (0)