Skip to content

Commit 1f37f61

Browse files
committed
fix rename
1 parent 17d6dc0 commit 1f37f61

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

src/contents.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,12 +526,16 @@ export class Drive implements Contents.IDrive {
526526
data = {
527527
name: newFileName,
528528
path: PathExt.join(currentDrive.name, result.formattedNewPath!),
529-
last_modified: result.response.data.last_modified,
529+
last_modified:
530+
result.response.length > 0
531+
? result.response.data.last_modified
532+
: '',
530533
created: '',
531534
content: PathExt.extname(newFileName) !== '' ? null : [], // TODO: add dir check
532535
format: result.format!,
533536
mimetype: result.mimetype!,
534-
size: result.response.data.size,
537+
size:
538+
result.response.length > 0 ? result.response.data.size : undefined,
535539
writable: true,
536540
type: result.type!
537541
};

src/requests.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -303,25 +303,31 @@ export async function renameObjects(
303303
})
304304
);
305305
}
306+
307+
let resp: any = {};
308+
let result = {
309+
response: resp,
310+
formattedNewPath: formattedNewPath,
311+
format: fileFormat as Contents.FileFormat,
312+
mimetype: fileMimeType,
313+
type: fileType
314+
};
306315
// always rename the object (file or main directory)
307316
try {
308317
const renamedObject = await Private.renameSingleObject(
309318
driveName,
310319
options.path,
311320
formattedNewPath
312321
);
313-
return {
314-
response: renamedObject,
315-
formattedNewPath: formattedNewPath,
316-
format: fileFormat as Contents.FileFormat,
317-
mimetype: fileMimeType,
318-
type: fileType
322+
resp = {
323+
last_modified: renamedObject.data.last_modified,
324+
size: renamedObject.data.size
319325
};
320326
} catch (error) {
321327
// renaming failed if directory didn't exist and was only part of a path
322328
}
323329

324-
return {};
330+
return result;
325331
}
326332

327333
/**

0 commit comments

Comments
 (0)