From 56662e5a1e903bd859b8aa095d9b73c281786a6d Mon Sep 17 00:00:00 2001 From: Peifan Li Date: Sat, 27 Dec 2025 22:52:38 -0500 Subject: [PATCH] refactor: Consolidate file moving operations into file manager --- .../storageService/collectionFileManager.ts | 473 ++++++++++++ .../storageService/collectionRepository.ts | 253 +++++++ .../services/storageService/collections.ts | 705 ++---------------- 3 files changed, 792 insertions(+), 639 deletions(-) create mode 100644 backend/src/services/storageService/collectionFileManager.ts create mode 100644 backend/src/services/storageService/collectionRepository.ts diff --git a/backend/src/services/storageService/collectionFileManager.ts b/backend/src/services/storageService/collectionFileManager.ts new file mode 100644 index 0000000..d841c23 --- /dev/null +++ b/backend/src/services/storageService/collectionFileManager.ts @@ -0,0 +1,473 @@ +import fs from "fs-extra"; +import path from "path"; +import { + IMAGES_DIR, + SUBTITLES_DIR, + UPLOADS_DIR, + VIDEOS_DIR, +} from "../../config/paths"; +import { logger } from "../../utils/logger"; +import { findImageFile, findVideoFile, moveFile } from "./fileHelpers"; +import { getSettings } from "./settings"; +import { Collection, Video } from "./types"; + +/** + * File manager layer for collection-related file operations + * This module handles all file system operations when videos are added/removed from collections + */ + +export interface FileMoveResult { + updated: boolean; + updates: Partial