Skip to content

Commit b582795

Browse files
committed
add support to view google drive new shortcut
1 parent 039a714 commit b582795

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

worker/dist/worker.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ self.props = {
333333
supportsAllDrives: true,
334334
q: `'${id}' in parents and trashed = false`,
335335
orderBy: 'folder,name,modifiedTime desc',
336-
fields: 'files(id,name,mimeType,size,modifiedTime),nextPageToken',
336+
fields: 'files(id,name,mimeType,size,modifiedTime,shortcutDetails),nextPageToken',
337337
pageSize: 1000
338338
};
339339

@@ -355,6 +355,12 @@ self.props = {
355355
pageToken = resp.nextPageToken;
356356
} while (pageToken);
357357

358+
files.forEach(file => {
359+
if (file && file.mimeType == 'application/vnd.google-apps.shortcut') {
360+
file.id = file.shortcutDetails.targetId;
361+
file.mimeType = file.shortcutDetails.targetMimeType;
362+
}
363+
});
358364
return {
359365
files
360366
};
@@ -390,7 +396,7 @@ self.props = {
390396
includeItemsFromAllDrives: true,
391397
supportsAllDrives: true,
392398
q: `'${parentId}' in parents and name = '${childName}' and trashed = false`,
393-
fields: 'files(id)'
399+
fields: 'files(id,shortcutDetails)'
394400
}
395401
}).json().catch(e => ({
396402
files: []
@@ -400,6 +406,10 @@ self.props = {
400406
return null;
401407
}
402408

409+
if (resp.files[0].shortcutDetails) {
410+
resp.files[0].id = resp.files[0].shortcutDetails.targetId;
411+
}
412+
403413
this._getIdCache.has(parentId + childName);
404414

405415
return resp.files[0].id; // when there are more than 1 items, simply return the first one

worker/googleDrive.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class GoogleDrive {
7575
q: `'${id}' in parents and trashed = false`,
7676
orderBy: 'folder,name,modifiedTime desc',
7777
fields:
78-
'files(id,name,mimeType,size,modifiedTime),nextPageToken',
78+
'files(id,name,mimeType,size,modifiedTime,shortcutDetails),nextPageToken',
7979
pageSize: 1000
8080
}
8181
if (pageToken) {
@@ -94,6 +94,12 @@ class GoogleDrive {
9494
files.push(...resp.files)
9595
pageToken = resp.nextPageToken
9696
} while (pageToken)
97+
files.forEach(file => {
98+
if (file && file.mimeType == 'application/vnd.google-apps.shortcut') {
99+
file.id = file.shortcutDetails.targetId;
100+
file.mimeType = file.shortcutDetails.targetMimeType;
101+
}
102+
});
97103
return { files }
98104
}
99105
async listFolderByPath(path, rootId = 'root') {
@@ -121,14 +127,17 @@ class GoogleDrive {
121127
includeItemsFromAllDrives: true,
122128
supportsAllDrives: true,
123129
q: `'${parentId}' in parents and name = '${childName}' and trashed = false`,
124-
fields: 'files(id)'
130+
fields: 'files(id,shortcutDetails)'
125131
}
126132
})
127133
.json()
128134
.catch(e => ({ files: [] })) // if error, make it empty
129135
if (resp.files.length === 0) {
130136
return null
131137
}
138+
if (resp.files[0].shortcutDetails){
139+
resp.files[0].id = resp.files[0].shortcutDetails.targetId;
140+
}
132141
this._getIdCache.has(parentId + childName)
133142
return resp.files[0].id // when there are more than 1 items, simply return the first one
134143
}

0 commit comments

Comments
 (0)