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
fix(backend:files): move trashed files to their canonical database scope
johavenaa2154771943
diff --git a/backend/src/applications/files/services/files-manager.service.spec.ts b/backend/src/applications/files/services/files-manager.service.spec.tsindex 61fddb3c..007e2d14 100644--- a/backend/src/applications/files/services/files-manager.service.spec.ts+++ b/backend/src/applications/files/services/files-manager.service.spec.ts@@ -57,6 +57,7 @@ describe(FilesManager.name, () => {const user = { id: 7, login: 'john', tmpPath: '/data/users/john/tmp' } as anyconst targetTmpRoot = '/data/users/john/.sync-in-tmp/users/7'+ const targetTrashDbScope = { ownerId: 7, spaceId: null, spaceExternalRootId: null, shareExternalId: null, inTrash: true }const temporaryPath = (operation: FILE_OPERATION, executionId: string, name: string, parentPath = targetTmpRoot): string =>path.join(parentPath, `${filesUtils.temporaryFilePrefix(operation, executionId)}${path.basename(name)}`)@@ -211,6 +212,7 @@ describe(FilesManager.name, () => {vi.spyOn(spacesPermsUtils, 'canAccessToSpace').mockReturnValue(true)vi.spyOn(spacesPermsUtils, 'haveSpaceEnvPermissions').mockReturnValue(true)vi.spyOn(spacesPathUtils, 'trashTargetFromSpace').mockReturnValue({+ dbScope: targetTrashDbScope,mode: 'trash',path: '/data/users/john/trash',temporaryRoot: targetTmpRoot@@ -1053,6 +1055,47 @@ describe(FilesManager.name, () => {expect(emitSpy).toHaveBeenCalledWith('event', { user, space: dst, action: ACTION.ADD, rPath: '/dst-base/dst.txt' })})+ it('should restore a space-trash entry into an external root with the destination db scope', async () => {+ const src = makeSpace({+ id: 11,+ repository: 'trash',+ url: 'trash/project/documents/report.txt',+ inTrashRepository: true,+ inPersonalSpace: false,+ realPath: '/data/spaces/project/trash/documents/report.txt',+ realBasePath: '/data/spaces/project/trash',+ dbFile: {+ ownerId: null,+ spaceId: 11,+ spaceExternalRootId: null,+ shareExternalId: null,+ path: 'documents/report.txt',+ inTrash: true+ }+ })+ const dst = makeSpace({+ id: 11,+ url: 'files/project/archive/restored/report.txt',+ inPersonalSpace: false,+ realPath: '/mnt/archive/restored/report.txt',+ realBasePath: '/mnt/archive',+ dbFile: {+ ownerId: null,+ spaceId: 11,+ spaceExternalRootId: 22,+ shareExternalId: null,+ path: 'restored/report.txt',+ inTrash: false+ }+ })+ prepareFileTransfer(src.realPath, dst.realPath)++ await service.copyMove(user, src, dst, true)++ expect(filesUtils.moveFiles).toHaveBeenCalledWith(src.realPath, dst.realPath, false)+ expect(filesQueries.moveFiles).toHaveBeenCalledWith(src.dbFile, dst.dbFile, false)+ })+it('should update the database before reporting an abortable move source cleanup failure', async () => {const src = makeSpace({url: 'files/source/src.txt',@@ -1139,7 +1182,11 @@ describe(FilesManager.name, () => {describe('delete', () => {it('should remove trash file, locks and db entries', async () => {- const space = makeSpace({ inTrashRepository: true, realPath: '/data/users/john/trash/old.txt' })+ const space = makeSpace({+ inTrashRepository: true,+ realPath: '/data/users/john/trash/old.txt',+ dbFile: { ...targetTrashDbScope, path: 'old.txt' }+ })vi.mocked(filesUtils.isPathExists).mockResolvedValueOnce(true)vi.mocked(filesUtils.isPathIsDir).mockResolvedValueOnce(true)filesLockManager.getLocksByPath.mockResolvedValueOnce([{ key: 'lk-1' }])@@ -1201,7 +1248,8 @@ describe(FilesManager.name, () => {expect(filesTasksTransfer.delete).toHaveBeenCalledWith(space, trashFile, targetTmpRoot, false, signal, expect.any(Function))expect(filesUtils.moveFiles).not.toHaveBeenCalled()- expect(filesQueries.deleteFiles).toHaveBeenCalledWith(space.dbFile, false, false)+ expect(filesQueries.moveFiles).toHaveBeenCalledWith(space.dbFile, { ...targetTrashDbScope, path: 'documents/document.txt' }, false)+ expect(filesQueries.deleteFiles).not.toHaveBeenCalled()})it('should keep the regular move path outside a task context', async () => {@@ -1217,8 +1265,48 @@ describe(FilesManager.name, () => {expect(filesUtils.moveFiles).toHaveBeenCalledWith(space.realPath, trashFile, true)expect(filesTasksTransfer.delete).not.toHaveBeenCalled()+ expect(filesQueries.moveFiles).toHaveBeenCalledWith(space.dbFile, { ...targetTrashDbScope, path: 'documents/document.txt' }, false)+ expect(filesQueries.deleteFiles).not.toHaveBeenCalled()expect(emitSpy).toHaveBeenCalledWith('event', { user, space, action: ACTION.DELETE, rPath: trashFile })})++ it('should move an external-root db entry into the canonical space-trash scope and preserve a collision', async () => {+ const sourceDb = {+ ownerId: null,+ spaceId: 11,+ spaceExternalRootId: 22,+ shareExternalId: null,+ path: 'documents/report.txt',+ inTrash: false+ }+ const trashDbScope = { ownerId: null, spaceId: 11, spaceExternalRootId: null, shareExternalId: null, inTrash: true }+ const trashDb = { ...trashDbScope, path: sourceDb.path }+ const space = makeSpace({+ id: 11,+ alias: 'project',+ inPersonalSpace: false,+ realPath: '/mnt/archive/documents/report.txt',+ dbFile: sourceDb+ })+ const trashFile = '/data/spaces/project/trash/documents/report.txt'+ const renamedTrashFile = '/data/spaces/project/trash/documents/report-2026.txt'+ vi.mocked(spacesPathUtils.trashTargetFromSpace).mockReturnValueOnce({+ dbScope: trashDbScope,+ mode: 'trash',+ path: '/data/spaces/project/trash',+ temporaryRoot: '/data/spaces/project/tmp/users/7'+ })+ prepareFileTransfer(space.realPath, trashFile, true)+ vi.mocked(filesUtils.uniqueDatedFilePath).mockResolvedValueOnce({ isDir: false, path: renamedTrashFile })++ await service.delete(user, space)++ expect(filesUtils.moveFiles).toHaveBeenNthCalledWith(1, trashFile, renamedTrashFile)+ expect(filesUtils.moveFiles).toHaveBeenNthCalledWith(2, space.realPath, trashFile, true)+ expect(filesQueries.moveFiles).toHaveBeenNthCalledWith(1, trashDb, { ...trashDbScope, path: 'documents/report-2026.txt' }, false)+ expect(filesQueries.moveFiles).toHaveBeenNthCalledWith(2, sourceDb, trashDb, false)+ expect(filesQueries.deleteFiles).not.toHaveBeenCalled()+ })})describe('downloadFromUrl', () => {diff --git a/backend/src/applications/files/services/files-manager.service.ts b/backend/src/applications/files/services/files-manager.service.tsindex 34230920..8489c240 100644--- a/backend/src/applications/files/services/files-manager.service.ts+++ b/backend/src/applications/files/services/files-manager.service.ts@@ -562,12 +562,15 @@ export class FilesManager {// file system deletionlet forceDeleteInDB = falselet sourceCleanupError: SourceCleanupError | undefined+ let trashDbFile: FileDBProps | undefinedif (space.inTrashRepository) {await removeFiles(space.realPath)FileEvent.emit('event', { user, space, action: ACTION.DELETE_PERMANENTLY, rPath: space.realPath })} else {const trashTarget = trashTargetFromSpace(user, space)if (trashTarget?.mode === 'trash') {+ const destinationDbFile: FileDBProps = { ...trashTarget.dbScope, path: space.dbFile.path }+ trashDbFile = destinationDbFileconst name = fileName(space.realPath)const trashDir = path.join(trashTarget.path, dirName(space.dbFile.path))const trashFile = path.join(trashDir, name)@@ -576,10 +579,10 @@ export class FilesManager {}if (isTaskContext) {sourceCleanupError = await this.filesTasksTransfer.delete(space, trashFile, trashTarget.temporaryRoot, isDir, signal, () =>- this.moveExistingTrashFile(space, trashFile)+ this.moveExistingTrashFile(trashFile, destinationDbFile))} else {- await this.moveExistingTrashFile(space, trashFile)+ await this.moveExistingTrashFile(trashFile, destinationDbFile)await moveFiles(space.realPath, trashFile, true)}// emit an event for the file or directory moved to the trash@@ -607,7 +610,11 @@ export class FilesManager {this.filesLockManager.removeLock(lock.key).catch((e: Error) => this.logger.error({ tag: this.delete.name, msg: `${e}` }))}// Keep the database aligned with the completed filesystem operation before reporting a residual source.- await this.filesQueries.deleteFiles(space.dbFile, isDir, forceDeleteInDB)+ if (trashDbFile) {+ await this.filesQueries.moveFiles(space.dbFile, trashDbFile, isDir)+ } else {+ await this.filesQueries.deleteFiles(space.dbFile, isDir, forceDeleteInDB)+ }if (sourceCleanupError) {this.logSourceCleanupError(sourceCleanupError)throw sourceCleanupError@@ -843,11 +850,10 @@ export class FilesManager {}}- private async moveExistingTrashFile(space: SpaceEnv, trashFile: string): Promise<void> {+ private async moveExistingTrashFile(trashFile: string, trashFileDB: FileDBProps): Promise<void> {if (!(await isPathExists(trashFile))) returnconst dstTrash = await uniqueDatedFilePath(trashFile)await moveFiles(trashFile, dstTrash.path)- const trashFileDB: FileDBProps = { ...space.dbFile, inTrash: true }const dstTrashFileDB: FileDBProps = { ...trashFileDB, path: path.join(dirName(trashFileDB.path), fileName(dstTrash.path)) }await this.filesQueries.moveFiles(trashFileDB, dstTrashFileDB, dstTrash.isDir)}diff --git a/backend/src/applications/spaces/spaces.md b/backend/src/applications/spaces/spaces.mdindex daea15ca..00c1dfe7 100644--- a/backend/src/applications/spaces/spaces.md+++ b/backend/src/applications/spaces/spaces.md@@ -1,7 +1,6 @@# Spaces-The `spaces` module manages collaborative spaces, anchored roots, external-roots, and the logical repositories used to browse their files and trash.+The `spaces` module manages collaborative spaces, anchored roots, external roots, and the logical repositories used to browse their files and trash.## Managed space storage@@ -16,21 +15,17 @@ spaces/<space-alias>/└── <actor-id>/```-The `files` and `trash` directories are created with the space. Temporary-directories are created lazily when an operation needs them.+The `files` and `trash` directories are created with the space. Temporary directories are created lazily when an operation needs them.-An external root is only a view of an existing filesystem location. Sync-in-does not create a trash directory inside it:+An external root is only a view of an existing filesystem location. Sync-in does not create a trash directory inside it:```text<external-root>/└── <existing-content>```-In particular, `<external-root>/.trash/` is not part of the storage layout.-Such a directory would not correspond to a logical trash repository, so the-trash list, browser, restore operations, and retention scheduler could not-discover or empty it.+In particular, `<external-root>/.trash/` is not part of the storage layout. Such a directory would not correspond to a logical trash repository, so+the trash list, browser, restore operations, and retention scheduler could not discover or empty it.## Logical trash repositories@@ -41,79 +36,74 @@ trash/personal/<path>trash/<space-alias>/<path>```-Every segment after `personal` or `<space-alias>` is treated as a path inside-the selected trash. A space root alias is therefore not resolved while browsing-trash. For an external root, the trash path is relative to the external root-itself and does not include its alias.+Every segment after `personal` or `<space-alias>` is treated as a path inside the selected trash. A space root alias is therefore not resolved while+browsing trash. For an external root, the trash path is relative to the external root itself and does not include its alias.-The trash list examines the personal trash and every space available to the-user. It returns only repositories containing at least one visible top-level-entry. Internal temporary entries are always ignored; hidden entries follow the+The trash list examines the personal trash and every space available to the user. It returns only repositories containing at least one visible+top-level entry. Internal temporary entries are always ignored; hidden entries follow the`showHiddenFiles` configuration.## Deletion target resolution-Deletion resolves one authoritative target from the source context and its-managed ownership:+Deletion resolves one authoritative target from the source context and its managed ownership:-| Source | Deletion target |-| --- | --- |-| Personal files | `users/<actor-login>/trash/` |-| Files stored in a native space home | `spaces/<space-alias>/trash/` |-| External root attached to a native space | `spaces/<space-alias>/trash/` |-| Root anchored to another user's personal files | `users/<owner-login>/trash/` |-| Share backed by personal files | `users/<owner-login>/trash/` |+| Source | Deletion target |+|-------------------------------------------------------|--------------------------------------|+| Personal files | `users/<actor-login>/trash/` |+| Files stored in a native space home | `spaces/<space-alias>/trash/` |+| External root attached to a native space | `spaces/<space-alias>/trash/` |+| Root anchored to another user's personal files | `users/<owner-login>/trash/` |+| Share backed by personal files | `users/<owner-login>/trash/` || Native-space-backed share, including an external root | `spaces/<origin-space-alias>/trash/` |-| External share | Permanent deletion |+| External share | Permanent deletion |-The authenticated user is the actor. The owner is the user or native space-whose managed storage contains, or logically owns, the source.+The authenticated user is the actor. The owner is the user or native space whose managed storage contains, or logically owns, the source.-An external root attached to a native space deliberately uses the native-space's managed trash. An external share has no managed storage owner and is+An external root attached to a native space deliberately uses the native space's managed trash. An external share has no managed storage owner and isdeleted permanently, regardless of the actor type. There is no fallback to`<external-root>/.trash/` and no migration from such a directory.## Deletion lifecycle-For a resource whose target is a managed trash, deletion performs the following-operations:+For a resource whose target is a managed trash, deletion performs the following operations:1. Resolve the managed trash and its temporary root from the source space.2. Recreate the source's relative parent path in that trash when required.-3. If the destination name already exists, preserve the existing trash entry- under a dated unique name.+3. If the destination name already exists, preserve the existing trash entry under a dated unique name in both the filesystem and database.4. Move the resource to the selected trash.-5. Mark the corresponding database records as being in trash and remove their- locks.+5. Move the corresponding database records into the trash's canonical scope and remove their locks.-The newly deleted resource keeps its original name. When a deletion runs as a-cancellable task and the source and trash are on different filesystems, it can-stage the transfer in the temporary directory belonging to the selected-managed trash before publishing it.+The newly deleted resource keeps its original name. When a deletion runs as a cancellable task and the source and trash are on different filesystems,+it can stage the transfer in the temporary directory belonging to the selected managed trash before publishing it.-For an external share, deletion skips this lifecycle and removes the source-directly from the filesystem and database.+Trash database scopes follow the managed owner, independently of the source root:-Deleting a resource that is already under `trash/...` removes it permanently-from the filesystem and database. The trash itself is a protected virtual-endpoint and cannot be deleted. New files, uploads, and in-place modifications-are rejected in trash; a resource can be restored by moving it from trash to a-writable files repository.+| Trash | Canonical database scope |+|--------------|-----------------------------------------------------------------------------------------------------------------|+| Personal | `ownerId = <owner>`, `spaceId = null`, `spaceExternalRootId = null`, `shareExternalId = null`, `inTrash = true` |+| Native space | `ownerId = null`, `spaceId = <space>`, `spaceExternalRootId = null`, `shareExternalId = null`, `inTrash = true` |++Moving an entry into trash updates its existing database record rather than deleting and recreating it. Its file identifier and attached relations are+therefore preserved. A collision is resolved against the canonical destination scope before the incoming record is moved into it. In particular,+entries from different external roots converge on the same native-space trash scope.++For an external share, deletion skips this lifecycle and removes the source directly from the filesystem and database.++Deleting a resource that is already under `trash/...` removes it permanently from the filesystem and database. The trash itself is a protected virtual+endpoint and cannot be deleted. New files, uploads, and in-place modifications are rejected in trash; a resource can be restored by moving it from+trash to a writable files repository. That move replaces the canonical trash scope with the selected destination scope, including an external-root+identifier when the destination is an external root.## Events and quotasA deletion that remains in the same logical ownership scope emits a `DELETE`-event. It does not trigger a quota update because moving an entry into trash is-not considered a logical storage removal.+event. It does not trigger a quota update because moving an entry into trash is not considered a logical storage removal.-An external share has no managed owner or trash destination. Its resources are-removed directly and emit `DELETE_PERMANENTLY`.+An external share has no managed owner or trash destination. Its resources are removed directly and emit `DELETE_PERMANENTLY`.## Automatic retention-Trash retention is configured independently for user and native-space-repositories:+Trash retention is configured independently for user and native-space repositories:```yamlapplications:@@ -123,16 +113,12 @@ applications:spaces: false```-Each value accepts a positive integer number of days. `false` or `0` disables-cleanup for that repository type. Cleanup runs at application startup and then-daily at 02:00 according to the server scheduler.+Each value accepts a positive integer number of days. `false` or `0` disables cleanup for that repository type. Cleanup runs at application startup+and then daily at 02:00 according to the server scheduler.-For space retention, only enabled native spaces are indexed. The scheduler-scans `spaces/<space-alias>/trash/`, records entries in disposable retention-tables, removes expired files before directories, and retries filesystem-deletion failures on a later run. Paths loaded from retention tables are-resolved and checked against the managed trash root before deletion.+For space retention, only enabled native spaces are indexed. The scheduler scans `spaces/<space-alias>/trash/`, records entries in disposable+retention tables, removes expired files before directories, and retries filesystem deletion failures on a later run. Paths loaded from retention+tables are resolved and checked against the managed trash root before deletion.-Retention never scans external roots for `.trash` directories. All deletions-owned by a native space are visible to the same browser and retention flow-because they converge on `spaces/<space-alias>/trash/`.+Retention never scans external roots for `.trash` directories. All deletions owned by a native space are visible to the same browser and retention+flow because they converge on `spaces/<space-alias>/trash/`.diff --git a/backend/src/applications/spaces/utils/paths.spec.ts b/backend/src/applications/spaces/utils/paths.spec.tsindex 62a4088c..19019bae 100644--- a/backend/src/applications/spaces/utils/paths.spec.ts+++ b/backend/src/applications/spaces/utils/paths.spec.ts@@ -17,6 +17,7 @@ vi.mock('../../../configuration/config.environment', () => ({describe('temporary path resolution', () => {const user = new UserModel({ id: 42, login: 'alice', role: USER_ROLE.USER } as any)+ const emptyTrashDbScope = { ownerId: null, spaceId: null, spaceExternalRootId: null, shareExternalId: null, inTrash: true }it('places personal-space artifacts in the personal storage root', () => {expect(temporaryRootFromSpace(user, { inPersonalSpace: true } as any)).toBe('/data/users/alice/.sync-in-tmp/users/42')@@ -58,28 +59,44 @@ describe('temporary path resolution', () => {it('resolves trash and staging together from the target space', () => {expect(trashTargetFromSpace(user, { inPersonalSpace: true } as any)).toEqual({+ dbScope: { ...emptyTrashDbScope, ownerId: 42 },mode: 'trash',path: '/data/users/alice/trash',temporaryRoot: '/data/users/alice/.sync-in-tmp/users/42'})- expect(trashTargetFromSpace(user, { alias: 'project' } as any)).toEqual({+ expect(trashTargetFromSpace(user, { id: 1, alias: 'project' } as any)).toEqual({+ dbScope: { ...emptyTrashDbScope, spaceId: 1 },mode: 'trash',path: '/data/spaces/project/trash',temporaryRoot: '/data/spaces/project/tmp/users/42'})expect(trashTargetFromSpace(user, {+ id: 1,alias: 'project',root: { externalPath: '/mnt/archive' },inFilesRepository: true,inSharesRepository: false} as any)).toEqual({+ dbScope: { ...emptyTrashDbScope, spaceId: 1 },mode: 'trash',path: '/data/spaces/project/trash',temporaryRoot: '/data/spaces/project/tmp/users/42'})expect(trashTargetFromSpace(user, { root: { file: { space: { id: 1, alias: 'project' } } } } as any)).toEqual({+ dbScope: { ...emptyTrashDbScope, spaceId: 1 },+ mode: 'trash',+ path: '/data/spaces/project/trash',+ temporaryRoot: '/data/spaces/project/tmp/users/42'+ })+ expect(+ trashTargetFromSpace(user, {+ root: { externalPath: '/mnt/archive', file: { space: { id: 1, alias: 'project' } } },+ inSharesRepository: true+ } as any)+ ).toEqual({+ dbScope: { ...emptyTrashDbScope, spaceId: 1 },mode: 'trash',path: '/data/spaces/project/trash',temporaryRoot: '/data/spaces/project/tmp/users/42'@@ -91,7 +108,8 @@ describe('temporary path resolution', () => {mode: 'permanent',reason: 'external-share'})- expect(trashTargetFromSpace(user, { root: { file: { path: 'documents' }, owner: { login: 'bob' } } } as any)).toEqual({+ expect(trashTargetFromSpace(user, { root: { file: { path: 'documents' }, owner: { id: 7, login: 'bob' } } } as any)).toEqual({+ dbScope: { ...emptyTrashDbScope, ownerId: 7 },mode: 'trash',path: '/data/users/bob/trash',temporaryRoot: '/data/users/bob/.sync-in-tmp/users/42'diff --git a/backend/src/applications/spaces/utils/paths.ts b/backend/src/applications/spaces/utils/paths.tsindex a5cd19b5..be69639e 100644--- a/backend/src/applications/spaces/utils/paths.ts+++ b/backend/src/applications/spaces/utils/paths.ts@@ -81,6 +81,7 @@ export function realPathFromSpace(user: UserModel, space: SpaceEnv, withBasePath}export interface TrashTarget {+ dbScope: Omit<FileDBProps, 'path'>mode: 'trash'path: stringtemporaryRoot: string@@ -94,12 +95,21 @@ export interface PermanentDeleteTarget {export type TrashTargetResolution = TrashTarget | PermanentDeleteTargetexport function trashTargetFromSpace(user: UserModel, space: SpaceEnv): TrashTargetResolution | null {- const userTarget = (login: string): TrashTarget => ({+ const baseDbScope: Omit<FileDBProps, 'path'> = {+ ownerId: null,+ spaceId: null,+ spaceExternalRootId: null,+ shareExternalId: null,+ inTrash: true+ }+ const userTarget = (ownerId: number, login: string): TrashTarget => ({+ dbScope: { ...baseDbScope, ownerId },mode: 'trash',path: UserModel.getTrashPath(login),temporaryRoot: temporaryRootFromStorage(UserModel.getHomePath(login), user.id)})- const spaceTarget = (alias: string): TrashTarget => ({+ const spaceTarget = (spaceId: number, alias: string): TrashTarget => ({+ dbScope: { ...baseDbScope, spaceId },mode: 'trash',path: SpaceModel.getTrashPath(alias),temporaryRoot: SpaceModel.getUserTmpPath(alias, user.id)@@ -107,14 +117,14 @@ export function trashTargetFromSpace(user: UserModel, space: SpaceEnv): TrashTarif (space.inPersonalSpace) {// personal user space- return userTarget(user.login)+ return userTarget(user.id, user.login)} else if (space.root?.externalPath) {// external path from space or share// space case: use the space trashif (space.root.file?.space?.alias) {- return spaceTarget(space.root.file.space.alias)+ return spaceTarget(space.root.file.space.id, space.root.file.space.alias)} else if (space.inFilesRepository && !space.inSharesRepository) {- return spaceTarget(space.alias)+ return spaceTarget(space.id, space.alias)}// external shares have no managed owner and are deleted permanentlyif (space.inSharesRepository) {@@ -123,13 +133,13 @@ export function trashTargetFromSpace(user: UserModel, space: SpaceEnv): TrashTarreturn null} else if (space.root?.file?.path && space.root.owner?.login) {// space root is linked to a file in a personal space- return userTarget(space.root.owner.login)+ return userTarget(space.root.owner.id, space.root.owner.login)} else if (space.root?.file?.space?.id) {// share linked to a space (with an external path or not)- return spaceTarget(space.root.file.space.alias)+ return spaceTarget(space.root.file.space.id, space.root.file.space.alias)} else if (space.alias) {// space files (no root)- return spaceTarget(space.alias)+ return spaceTarget(space.id, space.alias)}return null}