π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Inline
Manav Rathicf889b24af1d
diff --git a/web/apps/photos/src/services/watchFolder/utils.ts b/web/apps/photos/src/services/watchFolder/utils.tsdeleted file mode 100644index e69de29bb2..0000000000diff --git a/web/apps/photos/src/services/watchFolder/watchFolderEventHandlers.ts b/web/apps/photos/src/services/watchFolder/watchFolderEventHandlers.tsdeleted file mode 100644index ba4ad62ee3..0000000000--- a/web/apps/photos/src/services/watchFolder/watchFolderEventHandlers.ts+++ /dev/null@@ -1,73 +0,0 @@-import log from "@/next/log";-import { ElectronFile } from "types/upload";-import { EventQueueItem } from "types/watchFolder";-import watchFolderService from "./watchFolderService";--export async function diskFileAddedCallback(file: ElectronFile) {- try {- const collectionNameAndFolderPath =- await watchFolderService.getCollectionNameAndFolderPath(file.path);-- if (!collectionNameAndFolderPath) {- return;- }-- const { collectionName, folderPath } = collectionNameAndFolderPath;-- const event: EventQueueItem = {- type: "upload",- collectionName,- folderPath,- files: [file],- };- watchFolderService.pushEvent(event);- log.info(- `added (upload) to event queue, collectionName:${event.collectionName} folderPath:${event.folderPath}, filesCount: ${event.files.length}`,- );- } catch (e) {- log.error("error while calling diskFileAddedCallback", e);- }-}--export async function diskFileRemovedCallback(filePath: string) {- try {- const collectionNameAndFolderPath =- await watchFolderService.getCollectionNameAndFolderPath(filePath);-- if (!collectionNameAndFolderPath) {- return;- }-- const { collectionName, folderPath } = collectionNameAndFolderPath;-- const event: EventQueueItem = {- type: "trash",- collectionName,- folderPath,- paths: [filePath],- };- watchFolderService.pushEvent(event);- log.info(- `added (trash) to event queue collectionName:${event.collectionName} folderPath:${event.folderPath} , pathsCount: ${event.paths.length}`,- );- } catch (e) {- log.error("error while calling diskFileRemovedCallback", e);- }-}--export async function diskFolderRemovedCallback(folderPath: string) {- try {- const mappings = await watchFolderService.getWatchMappings();- const mapping = mappings.find(- (mapping) => mapping.folderPath === folderPath,- );- if (!mapping) {- log.info(`folder not found in mappings, ${folderPath}`);- throw Error(`Watch mapping not found`);- }- watchFolderService.pushTrashedDir(folderPath);- log.info(`added trashedDir, ${folderPath}`);- } catch (e) {- log.error("error while calling diskFolderRemovedCallback", e);- }-}diff --git a/web/apps/photos/src/services/watchFolder/watchFolderService.ts b/web/apps/photos/src/services/watchFolder/watchFolderService.tsindex ac0ca3a885..386b3efa60 100644--- a/web/apps/photos/src/services/watchFolder/watchFolderService.ts+++ b/web/apps/photos/src/services/watchFolder/watchFolderService.ts@@ -15,13 +15,8 @@ import { groupFilesBasedOnCollectionID } from "utils/file";import { getValidFilesToUpload } from "utils/watch";import { removeFromCollection } from "../collectionService";import { getLocalFiles } from "../fileService";-import {- diskFileAddedCallback,- diskFileRemovedCallback,- diskFolderRemovedCallback,-} from "./watchFolderEventHandlers";-class watchFolderService {+class WatchFolderService {private eventQueue: EventQueueItem[] = [];private currentEvent: EventQueueItem;private currentlySyncedMapping: WatchMapping;@@ -640,10 +635,81 @@ class watchFolderService {}}-export default new watchFolderService();+const watchFolderService = new WatchFolderService();++export default watchFolderService;-export const getParentFolderName = (filePath: string) => {+const getParentFolderName = (filePath: string) => {const folderPath = filePath.substring(0, filePath.lastIndexOf("/"));const folderName = folderPath.substring(folderPath.lastIndexOf("/") + 1);return folderName;};++async function diskFileAddedCallback(file: ElectronFile) {+ try {+ const collectionNameAndFolderPath =+ await watchFolderService.getCollectionNameAndFolderPath(file.path);++ if (!collectionNameAndFolderPath) {+ return;+ }++ const { collectionName, folderPath } = collectionNameAndFolderPath;++ const event: EventQueueItem = {+ type: "upload",+ collectionName,+ folderPath,+ files: [file],+ };+ watchFolderService.pushEvent(event);+ log.info(+ `added (upload) to event queue, collectionName:${event.collectionName} folderPath:${event.folderPath}, filesCount: ${event.files.length}`,+ );+ } catch (e) {+ log.error("error while calling diskFileAddedCallback", e);+ }+}++async function diskFileRemovedCallback(filePath: string) {+ try {+ const collectionNameAndFolderPath =+ await watchFolderService.getCollectionNameAndFolderPath(filePath);++ if (!collectionNameAndFolderPath) {+ return;+ }++ const { collectionName, folderPath } = collectionNameAndFolderPath;++ const event: EventQueueItem = {+ type: "trash",+ collectionName,+ folderPath,+ paths: [filePath],+ };+ watchFolderService.pushEvent(event);+ log.info(+ `added (trash) to event queue collectionName:${event.collectionName} folderPath:${event.folderPath} , pathsCount: ${event.paths.length}`,+ );+ } catch (e) {+ log.error("error while calling diskFileRemovedCallback", e);+ }+}++async function diskFolderRemovedCallback(folderPath: string) {+ try {+ const mappings = await watchFolderService.getWatchMappings();+ const mapping = mappings.find(+ (mapping) => mapping.folderPath === folderPath,+ );+ if (!mapping) {+ log.info(`folder not found in mappings, ${folderPath}`);+ throw Error(`Watch mapping not found`);+ }+ watchFolderService.pushTrashedDir(folderPath);+ log.info(`added trashedDir, ${folderPath}`);+ } catch (e) {+ log.error("error while calling diskFolderRemovedCallback", e);+ }+}