Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions worker/dist/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ self.props = {
supportsAllDrives: true,
q: `'${id}' in parents and trashed = false`,
orderBy: 'folder,name,modifiedTime desc',
fields: 'files(id,name,mimeType,size,modifiedTime),nextPageToken',
fields: 'files(id,name,mimeType,size,modifiedTime,shortcutDetails),nextPageToken',
pageSize: 1000
};

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

files.forEach(file => {
if (file && file.mimeType == 'application/vnd.google-apps.shortcut') {
file.id = file.shortcutDetails.targetId;
file.mimeType = file.shortcutDetails.targetMimeType;
}
});
return {
files
};
Expand Down Expand Up @@ -390,7 +396,7 @@ self.props = {
includeItemsFromAllDrives: true,
supportsAllDrives: true,
q: `'${parentId}' in parents and name = '${childName}' and trashed = false`,
fields: 'files(id)'
fields: 'files(id,shortcutDetails)'
}
}).json().catch(e => ({
files: []
Expand All @@ -400,6 +406,10 @@ self.props = {
return null;
}

if (resp.files[0].shortcutDetails) {
resp.files[0].id = resp.files[0].shortcutDetails.targetId;
}

this._getIdCache.has(parentId + childName);

return resp.files[0].id; // when there are more than 1 items, simply return the first one
Expand Down
13 changes: 11 additions & 2 deletions worker/googleDrive.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class GoogleDrive {
q: `'${id}' in parents and trashed = false`,
orderBy: 'folder,name,modifiedTime desc',
fields:
'files(id,name,mimeType,size,modifiedTime),nextPageToken',
'files(id,name,mimeType,size,modifiedTime,shortcutDetails),nextPageToken',
pageSize: 1000
}
if (pageToken) {
Expand All @@ -94,6 +94,12 @@ class GoogleDrive {
files.push(...resp.files)
pageToken = resp.nextPageToken
} while (pageToken)
files.forEach(file => {
if (file && file.mimeType == 'application/vnd.google-apps.shortcut') {
file.id = file.shortcutDetails.targetId;
file.mimeType = file.shortcutDetails.targetMimeType;
}
});
return { files }
}
async listFolderByPath(path, rootId = 'root') {
Expand Down Expand Up @@ -121,14 +127,17 @@ class GoogleDrive {
includeItemsFromAllDrives: true,
supportsAllDrives: true,
q: `'${parentId}' in parents and name = '${childName}' and trashed = false`,
fields: 'files(id)'
fields: 'files(id,shortcutDetails)'
}
})
.json()
.catch(e => ({ files: [] })) // if error, make it empty
if (resp.files.length === 0) {
return null
}
if (resp.files[0].shortcutDetails){
resp.files[0].id = resp.files[0].shortcutDetails.targetId;
}
this._getIdCache.has(parentId + childName)
return resp.files[0].id // when there are more than 1 items, simply return the first one
}
Expand Down