spl
This commit is contained in:
@@ -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,
|
||||
})),
|
||||
|
||||
@@ -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];
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user