Fixed file moves in Google Drive workspace
This commit is contained in:
parent
c3de3c1f84
commit
83bc227d9a
@ -127,6 +127,7 @@ export default providerRegistry.register({
|
||||
providerUtils.serializeContent(content),
|
||||
undefined,
|
||||
syncLocation.driveFileId,
|
||||
undefined,
|
||||
ifNotTooLate,
|
||||
)
|
||||
.then(driveFile => ({
|
||||
|
@ -260,7 +260,7 @@ export default providerRegistry.register({
|
||||
|
||||
// If change is on a data item
|
||||
if (change.file.parents[0] === workspace.dataFolderId) {
|
||||
// Data item has a JSON as a filename
|
||||
// Data item has a JSON filename
|
||||
try {
|
||||
change.item = JSON.parse(change.file.name);
|
||||
} catch (e) {
|
||||
@ -316,6 +316,7 @@ export default providerRegistry.register({
|
||||
// Build sync data
|
||||
change.syncData = {
|
||||
id: change.fileId,
|
||||
parentIds: change.file.parents,
|
||||
itemId: change.item.id,
|
||||
type: change.item.type,
|
||||
hash: change.item.hash,
|
||||
@ -363,6 +364,7 @@ export default providerRegistry.register({
|
||||
undefined,
|
||||
undefined,
|
||||
syncData && syncData.id,
|
||||
syncData && syncData.parentIds,
|
||||
ifNotTooLate,
|
||||
);
|
||||
}
|
||||
@ -379,6 +381,7 @@ export default providerRegistry.register({
|
||||
undefined,
|
||||
item.type === 'folder' ? googleHelper.folderMimeType : undefined,
|
||||
syncData && syncData.id,
|
||||
syncData && syncData.parentIds,
|
||||
ifNotTooLate,
|
||||
);
|
||||
})
|
||||
@ -464,6 +467,7 @@ export default providerRegistry.register({
|
||||
providerUtils.serializeContent(content),
|
||||
undefined,
|
||||
syncData.id,
|
||||
undefined,
|
||||
ifNotTooLate,
|
||||
);
|
||||
}
|
||||
@ -483,6 +487,7 @@ export default providerRegistry.register({
|
||||
providerUtils.serializeContent(content),
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
ifNotTooLate,
|
||||
)
|
||||
.then((file) => {
|
||||
@ -529,6 +534,7 @@ export default providerRegistry.register({
|
||||
JSON.stringify(item),
|
||||
undefined,
|
||||
syncData && syncData.id,
|
||||
syncData && syncData.parentIds,
|
||||
ifNotTooLate,
|
||||
)
|
||||
.then(file => store.dispatch('data/patchSyncData', {
|
||||
|
@ -74,6 +74,7 @@ export default {
|
||||
media = null,
|
||||
mediaType = null,
|
||||
fileId = null,
|
||||
oldParents = null,
|
||||
ifNotTooLate = cb => res => cb(res),
|
||||
) {
|
||||
return Promise.resolve()
|
||||
@ -83,12 +84,22 @@ export default {
|
||||
method: 'POST',
|
||||
url: 'https://www.googleapis.com/drive/v3/files',
|
||||
};
|
||||
const params = {
|
||||
supportsTeamDrives: true,
|
||||
};
|
||||
const metadata = { name, appProperties };
|
||||
if (fileId) {
|
||||
options.method = 'PATCH';
|
||||
options.url = `https://www.googleapis.com/drive/v3/files/${fileId}`;
|
||||
if (parents && oldParents) {
|
||||
params.addParents = parents
|
||||
.filter(parent => oldParents.indexOf(parent) === -1)
|
||||
.join(',');
|
||||
params.removeParents = oldParents
|
||||
.filter(parent => parents.indexOf(parent) === -1)
|
||||
.join(',');
|
||||
}
|
||||
} else if (parents) {
|
||||
// Parents field is not patchable
|
||||
metadata.parents = parents;
|
||||
}
|
||||
if (media) {
|
||||
@ -109,8 +120,8 @@ export default {
|
||||
return this.request(refreshedToken, {
|
||||
...options,
|
||||
params: {
|
||||
...params,
|
||||
uploadType: 'multipart',
|
||||
supportsTeamDrives: true,
|
||||
},
|
||||
headers: {
|
||||
'Content-Type': `multipart/mixed; boundary="${boundary}"`,
|
||||
@ -124,9 +135,7 @@ export default {
|
||||
return this.request(refreshedToken, {
|
||||
...options,
|
||||
body: metadata,
|
||||
params: {
|
||||
supportsTeamDrives: true,
|
||||
},
|
||||
params,
|
||||
}).then(res => res.body);
|
||||
}));
|
||||
},
|
||||
@ -399,7 +408,17 @@ export default {
|
||||
return getPage(startPageToken);
|
||||
});
|
||||
},
|
||||
uploadFile(token, name, parents, appProperties, media, mediaType, fileId, ifNotTooLate) {
|
||||
uploadFile(
|
||||
token,
|
||||
name,
|
||||
parents,
|
||||
appProperties,
|
||||
media,
|
||||
mediaType,
|
||||
fileId,
|
||||
oldParents,
|
||||
ifNotTooLate,
|
||||
) {
|
||||
return this.refreshToken(token, getDriveScopes(token))
|
||||
.then(refreshedToken => this.uploadFileInternal(
|
||||
refreshedToken,
|
||||
@ -409,6 +428,7 @@ export default {
|
||||
media,
|
||||
mediaType,
|
||||
fileId,
|
||||
oldParents,
|
||||
ifNotTooLate,
|
||||
));
|
||||
},
|
||||
@ -422,6 +442,7 @@ export default {
|
||||
media,
|
||||
undefined,
|
||||
fileId,
|
||||
undefined,
|
||||
ifNotTooLate,
|
||||
));
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user