π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Remove uses of path
Manav Rathif5754eb2e19f
diff --git a/web/apps/photos/src/components/Upload/Uploader.tsx b/web/apps/photos/src/components/Upload/Uploader.tsxindex fdc6ee9329..90b5f94b4e 100644--- a/web/apps/photos/src/components/Upload/Uploader.tsx+++ b/web/apps/photos/src/components/Upload/Uploader.tsx@@ -324,8 +324,8 @@ export default function Uploader({// Trigger an upload when any of the dependencies change.useEffect(() => {const allItemAndPaths = [- /* TODO(MR): ElectronFile | use webkitRelativePath || name here */- webFiles.map((f) => [f, f["path"] ?? f.name]),+ // See: [Note: webkitRelativePath]+ webFiles.map((f) => [f, f.webkitRelativePath ?? f.name]),desktopFiles.map((fp) => [fp, fp.path]),desktopFilePaths.map((p) => [p, p]),desktopZipItems.map((ze) => [ze, ze[1]]),diff --git a/web/packages/shared/hooks/useFileInput.tsx b/web/packages/shared/hooks/useFileInput.tsxindex 4eb346d39c..158a71b44e 100644--- a/web/packages/shared/hooks/useFileInput.tsx+++ b/web/packages/shared/hooks/useFileInput.tsx@@ -72,19 +72,27 @@ export default function useFileInput({event,) => {if (!!event.target && !!event.target.files) {- const files = [...event.target.files].map((file) =>- toFileWithPath(file),- );- setSelectedFiles(files);+ setSelectedFiles([...event.target.files]);}};+ // [Note: webkitRelativePath]+ //+ // If the webkitdirectory attribute of an <input> HTML element is set then+ // the File objects that we get will have `webkitRelativePath` property+ // containing the relative path to the selected directory.+ //+ // https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory+ const directoryOpts = directory+ ? { directory: "", webkitdirectory: "" }+ : {};+const getInputProps = useCallback(() => ({type: "file",multiple: true,style: { display: "none" },- ...(directory ? { directory: "", webkitdirectory: "" } : {}),+ ...directoryOpts,ref: inputRef,onChange: handleChange,...(accept ? { accept } : {}),@@ -98,26 +106,3 @@ export default function useFileInput({selectedFiles: selectedFiles,};}--// https://github.com/react-dropzone/file-selector/blob/master/src/file.ts#L88-export function toFileWithPath(file: File, path?: string): FileWithPath {- if (typeof (file as any).path !== "string") {- // on electron, path is already set to the absolute path- const { webkitRelativePath } = file;- Object.defineProperty(file, "path", {- value:- typeof path === "string"- ? path- : typeof webkitRelativePath === "string" && // If <input webkitdirectory> is set,- // the File will have a {webkitRelativePath} property- // https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory- webkitRelativePath.length > 0- ? webkitRelativePath- : file.name,- writable: false,- configurable: false,- enumerable: true,- });- }- return file;-}