album: fix error on removing live photo
parent
134a1bd898
commit
51a96e31bc
|
@ -230,15 +230,20 @@ export async function* deletePhotos(photos: IPhoto[]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const photosWithLive = await extendWithLivePhotos(photos);
|
// Extend with live photos unless this is an album
|
||||||
const fileIdsSet = new Set(photosWithLive.map((p) => p.fileid));
|
if (window.vueroute().name !== "albums") {
|
||||||
|
photos = await extendWithLivePhotos(photos);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get set of unique file ids
|
||||||
|
const fileIdsSet = new Set(photos.map((p) => p.fileid));
|
||||||
|
|
||||||
// Get files data
|
// Get files data
|
||||||
let fileInfos: IFileInfo[] = [];
|
let fileInfos: IFileInfo[] = [];
|
||||||
try {
|
try {
|
||||||
fileInfos = await getFiles(photosWithLive);
|
fileInfos = await getFiles(photos);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Failed to get file info for files to delete", photosWithLive, e);
|
console.error("Failed to get file info for files to delete", photos, e);
|
||||||
showError(t("memories", "Failed to delete files."));
|
showError(t("memories", "Failed to delete files."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -271,7 +276,11 @@ export async function* deletePhotos(photos: IPhoto[]) {
|
||||||
* @param overwrite behaviour if the target exists. `true` overwrites, `false` fails.
|
* @param overwrite behaviour if the target exists. `true` overwrites, `false` fails.
|
||||||
* @returns list of file ids that were moved
|
* @returns list of file ids that were moved
|
||||||
*/
|
*/
|
||||||
export async function* movePhotos(photos: IPhoto[], destination: string, overwrite: boolean) {
|
export async function* movePhotos(
|
||||||
|
photos: IPhoto[],
|
||||||
|
destination: string,
|
||||||
|
overwrite: boolean
|
||||||
|
) {
|
||||||
if (photos.length === 0) {
|
if (photos.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -279,19 +288,20 @@ export async function* movePhotos(photos: IPhoto[], destination: string, overwri
|
||||||
// Set absolute target path
|
// Set absolute target path
|
||||||
const prefixPath = `files/${getCurrentUser()?.uid}`;
|
const prefixPath = `files/${getCurrentUser()?.uid}`;
|
||||||
let targetPath = prefixPath + destination;
|
let targetPath = prefixPath + destination;
|
||||||
if (!targetPath.endsWith('/')) {
|
if (!targetPath.endsWith("/")) {
|
||||||
targetPath += '/';
|
targetPath += "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
const photosWithLive = await extendWithLivePhotos(photos);
|
// Also move the live photo videos
|
||||||
const fileIdsSet = new Set(photosWithLive.map((p) => p.fileid));
|
photos = await extendWithLivePhotos(photos);
|
||||||
|
const fileIdsSet = new Set(photos.map((p) => p.fileid));
|
||||||
|
|
||||||
// Get files data
|
// Get files data
|
||||||
let fileInfos: IFileInfo[] = [];
|
let fileInfos: IFileInfo[] = [];
|
||||||
try {
|
try {
|
||||||
fileInfos = await getFiles(photosWithLive);
|
fileInfos = await getFiles(photos);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Failed to get file info for files to move", photosWithLive, e);
|
console.error("Failed to get file info for files to move", photos, e);
|
||||||
showError(t("memories", "Failed to move files."));
|
showError(t("memories", "Failed to move files."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -304,7 +314,8 @@ export async function* movePhotos(photos: IPhoto[], destination: string, overwri
|
||||||
fileInfo.originalFilename,
|
fileInfo.originalFilename,
|
||||||
targetPath + fileInfo.basename,
|
targetPath + fileInfo.basename,
|
||||||
// @ts-ignore - https://github.com/perry-mitchell/webdav-client/issues/329
|
// @ts-ignore - https://github.com/perry-mitchell/webdav-client/issues/329
|
||||||
{ headers: { 'Overwrite' : overwrite ? 'T' : 'F' }});
|
{ headers: { Overwrite: overwrite ? "T" : "F" } }
|
||||||
|
);
|
||||||
return fileInfo.fileid;
|
return fileInfo.fileid;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Failed to move", fileInfo, error);
|
console.error("Failed to move", fileInfo, error);
|
||||||
|
|
Loading…
Reference in New Issue