Skip to content

Commit d020aa0

Browse files
committed
remove common data object
1 parent 1f37f61 commit d020aa0

File tree

1 file changed

+54
-17
lines changed

1 file changed

+54
-17
lines changed

src/contents.ts

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,6 @@ import {
2727
includeDrive
2828
} from './requests';
2929

30-
let data: Contents.IModel = {
31-
name: '',
32-
path: '',
33-
last_modified: '',
34-
created: '',
35-
content: [],
36-
format: null,
37-
mimetype: '',
38-
size: 0,
39-
writable: true,
40-
type: ''
41-
};
42-
4330
export class Drive implements Contents.IDrive {
4431
/**
4532
* Construct a new drive object.
@@ -227,6 +214,8 @@ export class Drive implements Contents.IDrive {
227214
localPath: string,
228215
options?: Contents.IFetchOptions
229216
): Promise<Contents.IModel> {
217+
let data: Contents.IModel;
218+
230219
if (localPath !== '') {
231220
const currentDrive = extractCurrentDrive(localPath, this._drivesList);
232221

@@ -329,6 +318,18 @@ export class Drive implements Contents.IDrive {
329318
async newUntitled(
330319
options: Contents.ICreateOptions = {}
331320
): Promise<Contents.IModel> {
321+
let data: Contents.IModel = {
322+
name: '',
323+
path: '',
324+
last_modified: '',
325+
created: '',
326+
content: [],
327+
format: null,
328+
mimetype: '',
329+
size: 0,
330+
writable: true,
331+
type: ''
332+
};
332333
const path = options.path ?? '';
333334

334335
if (path !== '') {
@@ -494,6 +495,18 @@ export class Drive implements Contents.IDrive {
494495
newLocalPath: string,
495496
options: Contents.ICreateOptions = {}
496497
): Promise<Contents.IModel> {
498+
let data: Contents.IModel = {
499+
name: '',
500+
path: '',
501+
last_modified: '',
502+
created: '',
503+
content: [],
504+
format: null,
505+
mimetype: '',
506+
size: 0,
507+
writable: true,
508+
type: ''
509+
};
497510
if (oldLocalPath !== '') {
498511
const currentDrive = extractCurrentDrive(oldLocalPath, this._drivesList);
499512

@@ -605,6 +618,18 @@ export class Drive implements Contents.IDrive {
605618
localPath: string,
606619
options: Partial<Contents.IModel> = {}
607620
): Promise<Contents.IModel> {
621+
let data: Contents.IModel = {
622+
name: '',
623+
path: '',
624+
last_modified: '',
625+
created: '',
626+
content: [],
627+
format: null,
628+
mimetype: '',
629+
size: 0,
630+
writable: true,
631+
type: ''
632+
};
608633
if (localPath !== '') {
609634
const currentDrive = extractCurrentDrive(localPath, this._drivesList);
610635
const currentPath = formatPath(localPath);
@@ -693,6 +718,18 @@ export class Drive implements Contents.IDrive {
693718
toDir: string,
694719
options: Contents.ICreateOptions = {}
695720
): Promise<Contents.IModel> {
721+
let data: Contents.IModel = {
722+
name: '',
723+
path: '',
724+
last_modified: '',
725+
created: '',
726+
content: [],
727+
format: null,
728+
mimetype: '',
729+
size: 0,
730+
writable: true,
731+
type: ''
732+
};
696733
if (path !== '') {
697734
const currentDrive = extractCurrentDrive(path, this._drivesList);
698735
const toDrive = extractCurrentDrive(toDir, this._drivesList);
@@ -757,7 +794,7 @@ export class Drive implements Contents.IDrive {
757794
location: region
758795
});
759796

760-
data = {
797+
const data: Contents.IModel = {
761798
name: newDriveName,
762799
path: newDriveName,
763800
last_modified: '',
@@ -790,7 +827,7 @@ export class Drive implements Contents.IDrive {
790827
async addPublicDrive(driveUrl: string): Promise<Contents.IModel> {
791828
await addPublicDrive(driveUrl);
792829

793-
data = {
830+
const data: Contents.IModel = {
794831
name: driveUrl,
795832
path: driveUrl,
796833
last_modified: '',
@@ -823,7 +860,7 @@ export class Drive implements Contents.IDrive {
823860
async excludeDrive(driveName: string): Promise<Contents.IModel> {
824861
await excludeDrive(driveName);
825862

826-
data = {
863+
const data: Contents.IModel = {
827864
name: driveName,
828865
path: driveName,
829866
last_modified: '',
@@ -856,7 +893,7 @@ export class Drive implements Contents.IDrive {
856893
async includeDrive(driveName: string): Promise<Contents.IModel> {
857894
await includeDrive(driveName);
858895

859-
data = {
896+
const data: Contents.IModel = {
860897
name: driveName,
861898
path: driveName,
862899
last_modified: '',

0 commit comments

Comments
 (0)