This commit is contained in:
Manav Rathi
2025-05-27 13:20:49 +05:30
parent 13b74f387f
commit aa70b2a437
3 changed files with 34 additions and 5 deletions

View File

@@ -30,6 +30,7 @@ import type { CollectionMapping, Electron, ZipItem } from "ente-base/types/ipc";
import { useFileInput } from "ente-gallery/components/utils/use-file-input";
import {
groupItemsBasedOnParentFolder,
uploadPathPrefix,
type FileAndPath,
type UploadItem,
type UploadItemAndPath,
@@ -562,7 +563,7 @@ export const Upload: React.FC<UploadProps> = ({
const uploadItemsWithCollection = uploadItemsAndPaths.current.map(
([uploadItem, path], index) => ({
uploadItem,
uploadItemPathPrefix: dirname(path),
uploadItemPathPrefix: uploadPathPrefix(path),
localID: index,
collectionID: collection.id,
}),
@@ -614,7 +615,7 @@ export const Upload: React.FC<UploadProps> = ({
...uploadItemsWithCollection,
...uploadItems.map(([uploadItem, path]) => ({
localID: index++,
uploadItemPathPrefix: dirname(path),
uploadItemPathPrefix: uploadPathPrefix(path),
collectionID: collection.id,
uploadItem,
})),

View File

@@ -163,9 +163,25 @@ export interface TimestampedFileSystemUploadItem {
*
* And can thus be used to associate the correct metadata JSON with the
* corresponding {@link UploadItem}.
*
* As a special case, "/metadata" at the end of the path prefix is discarded.
* This allows the metadata JSON written by export to be read back in during
* uploads. See: [Note: Fold "metadata" directory into parent folder].
*/
export type UploadPathPrefix = string;
/**
* Return the {@link UploadPathPrefix} for the given {@link pathOrName} of an
* item being uploaded.
*/
export const uploadPathPrefix = (pathOrName: string) => {
const folderPath = dirname(pathOrName);
if (basename(folderPath) == exportMetadataDirectoryName) {
return dirname(folderPath);
}
return folderPath;
};
export type UploadItemAndPath = [UploadItem, string];
/**

View File

@@ -254,14 +254,26 @@ export type ExternalParsedMetadata = ParsedMetadata & {
};
export interface UploadAsset {
/** `true` if this is a live photo. */
/**
* `true` if this is a live photo.
*/
isLivePhoto?: boolean;
/* Valid for live photos */
/**
* The two parts of the live photo being uploaded.
*
* Valid for live photos.
*/
livePhotoAssets?: LivePhotoAssets;
/* Valid for non-live photos */
/**
* The item being uploaded.
*
* Valid for non-live photos.
*/
uploadItem?: UploadItem;
/**
* The path prefix of the uploadItem, if available.
*
* Valid for non-live photos.
*/
uploadItemPathPrefix?: UploadPathPrefix;
/**