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