Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
refactor(backend:files): do not preserve timestamps during document creation
johavenab7b93995fa1
diff --git a/backend/src/applications/files/services/files-manager.service.ts b/backend/src/applications/files/services/files-manager.service.tsindex 19f737b8..cb7ae012 100644--- a/backend/src/applications/files/services/files-manager.service.ts+++ b/backend/src/applications/files/services/files-manager.service.ts@@ -244,8 +244,7 @@ export class FilesManager {const fileExtension = path.extname(space.realPath)if (checkDocument && fileExtension !== '.txt' && Object.values(DOCUMENT_TYPE).indexOf(fileExtension) > -1) {const srcSample = path.join(__dirname, `${SAMPLE_PATH_WITHOUT_EXT}${fileExtension}`)- await copyFiles(srcSample, space.realPath)- return touchFile(space.realPath)+ return copyFiles(srcSample, space.realPath, false, false, false)} else {return createEmptyFile(space.realPath)}diff --git a/backend/src/applications/files/utils/files.ts b/backend/src/applications/files/utils/files.tsindex ae8fc79b..847ead86 100644--- a/backend/src/applications/files/utils/files.ts+++ b/backend/src/applications/files/utils/files.ts@@ -136,17 +136,19 @@ export function touchFile(rPath: string, mtime?: number): Promise<void> {return fs.utimes(rPath, mtime, mtime)}-export async function copyFiles(srcPath: string, dstPath: string, overwrite = false, recursive = true): Promise<void> {+export async function copyFiles(srcPath: string, dstPath: string, overwrite = false, recursive = true, preserveTimestamps = true): Promise<void> {/*If src is a directory it will copy everything inside of this directory, not the entire directory itselfIf src is a file, dest cannot be a directory*/if (!recursive && (await isPathIsDir(srcPath))) {- const stat = await fs.stat(srcPath)await fs.mkdir(dstPath)- await fs.utimes(dstPath, stat.atime, stat.mtime)+ if (preserveTimestamps) {+ const stat = await fs.stat(srcPath)+ await fs.utimes(dstPath, stat.atime, stat.mtime)+ }} else {- await fse.copy(srcPath, dstPath, { overwrite, preserveTimestamps: true })+ await fse.copy(srcPath, dstPath, { overwrite, preserveTimestamps: preserveTimestamps })}}