From 3dfd35f1e31d3f4a90bf7537878778912b919717 Mon Sep 17 00:00:00 2001 From: ArceDanielShok Date: Wed, 4 Sep 2024 13:50:23 -0300 Subject: [PATCH] Implemented the changes for ticket PB-2692. Integrated the new endpoint to retrieve folder metadata during creation. This update ensures that when a folder is created, the correct metadata is fetched and stored, addressing the issues related to folder persistence and synchronization. --- src/apps/main/auth/handlers.ts | 4 +- src/apps/main/auth/refresh-token.ts | 39 +++++++++++++++- src/apps/main/auth/service.ts | 7 +-- src/apps/main/preload.d.ts | 7 +++ src/apps/main/preload.js | 7 +++ .../main/remote-sync/RemoteSyncManager.ts | 4 +- src/apps/main/types.ts | 1 + .../dependency-injection/common/traverser.ts | 3 +- .../dependency-injection/folders/builder.ts | 14 +++--- .../dependency-injection/items/builder.ts | 6 ++- src/context/shared/domain/ServerFolder.ts | 1 + .../folders/application/FolderCreator.ts | 4 +- .../folders/application/FolderDeleter.ts | 2 +- .../folders/application/FolderMover.ts | 2 +- .../application/FolderPlaceholderDeleter.ts | 2 +- .../folders/application/FolderRenamer.ts | 2 +- .../Offline/OfflineFolderCreator.ts | 7 ++- .../folders/domain/OfflineFolder.ts | 19 +++++++- ...oteFileSystem.ts => RemoteFolderSystem.ts} | 2 +- ...ileSystem.ts => HttpRemoteFolderSystem.ts} | 44 ++++++++++++++++++- .../items/application/Traverser.ts | 14 +++--- .../__mocks__/FolderRemoteFileSystemMock.ts | 2 +- 22 files changed, 157 insertions(+), 36 deletions(-) rename src/context/virtual-drive/folders/domain/file-systems/{RemoteFileSystem.ts => RemoteFolderSystem.ts} (91%) rename src/context/virtual-drive/folders/infrastructure/{HttpRemoteFileSystem.ts => HttpRemoteFolderSystem.ts} (72%) diff --git a/src/apps/main/auth/handlers.ts b/src/apps/main/auth/handlers.ts index 077d18da3..ff0570ab6 100644 --- a/src/apps/main/auth/handlers.ts +++ b/src/apps/main/auth/handlers.ts @@ -6,7 +6,7 @@ import { applicationOpened } from '../analytics/service'; import eventBus from '../event-bus'; import { setupRootFolder } from '../virtual-root-folder/service'; import { getWidget } from '../windows/widget'; -import { createTokenSchedule } from './refresh-token'; +import { checkUserData, createTokenSchedule } from './refresh-token'; import { canHisConfigBeRestored, encryptToken, @@ -79,7 +79,7 @@ eventBus.on('APP_IS_READY', async () => { if (!isLoggedIn) { return; } - + await checkUserData(); encryptToken(); applicationOpened(); await createTokenSchedule(); diff --git a/src/apps/main/auth/refresh-token.ts b/src/apps/main/auth/refresh-token.ts index 50a94a251..8099ee2a6 100644 --- a/src/apps/main/auth/refresh-token.ts +++ b/src/apps/main/auth/refresh-token.ts @@ -1,14 +1,21 @@ import Logger from 'electron-log'; -import { getClient } from '../../shared/HttpClient/main-process-client'; +import { + getClient, + getNewTokenClient, +} from '../../shared/HttpClient/main-process-client'; import { TokenScheduler } from '../token-scheduler/TokenScheduler'; import { onUserUnauthorized } from './handlers'; import { + getUser, obtainTokens as obtainStoredTokens, + setUser, updateCredentials, } from './service'; +import axios from 'axios'; const authorizedClient = getClient(); +const newAuthorizedClient = getNewTokenClient(); async function obtainTokens() { try { @@ -48,3 +55,33 @@ export async function createTokenSchedule(refreshedTokens?: Array) { createTokenSchedule(await refreshToken()); } } + +async function getRootFolderMetadata(rootFolderid: number) { + try { + const res = await newAuthorizedClient.get( + `${process.env.NEW_DRIVE_URL}/drive/folders/${rootFolderid}/metadata` + ); + + Logger.info('[AUTH] Got root folder metadata', res.data); + return res.data; + } catch (err) { + Logger.error('[AUTH] Could not get root folder metadata', err); + if (axios.isAxiosError(err)) { + Logger.error('[Is Axios Error]', err.response?.data); + } + return null; + } +} + +export async function checkUserData(): Promise { + const user = getUser(); + if (user?.root_folder_id && !user?.rootFolderId) { + const rootFolderMetadata = await getRootFolderMetadata(user.root_folder_id); + if (rootFolderMetadata) { + setUser({ + ...user, + rootFolderId: rootFolderMetadata.uuid, + }); + } + } +} diff --git a/src/apps/main/auth/service.ts b/src/apps/main/auth/service.ts index fb56ce325..167d2b3ee 100644 --- a/src/apps/main/auth/service.ts +++ b/src/apps/main/auth/service.ts @@ -86,6 +86,10 @@ export function setCredentials( ConfigStore.set('newTokenEncrypted', isSafeStorageAvailable); } +export function setUser(userData: User) { + ConfigStore.set('userData', userData); +} + export function updateCredentials( bearerToken: string, newBearerToken?: string @@ -146,7 +150,6 @@ export function getUser(): User | null { return user && Object.keys(user).length ? user : null; } - export function obtainTokens(): Array { return tokensKeys.map(obtainToken); } @@ -220,5 +223,3 @@ export function logout() { resetCredentials(); Logger.info('[AUTH] User logged out'); } - - diff --git a/src/apps/main/preload.d.ts b/src/apps/main/preload.d.ts index 6028d6622..12822ee49 100644 --- a/src/apps/main/preload.d.ts +++ b/src/apps/main/preload.d.ts @@ -11,6 +11,13 @@ declare interface Window { pathChanged(path: string): void; + logger: { + info: (...message: unknown[]) => void; + error: (...message: unknown[]) => void; + warn: (...message: unknown[]) => void; + debug: (...message: unknown[]) => void; + }; + getGeneralIssues: () => Promise< import('../../apps/shared/types').GeneralIssue[] >; diff --git a/src/apps/main/preload.js b/src/apps/main/preload.js index fce37a19c..1115029fc 100644 --- a/src/apps/main/preload.js +++ b/src/apps/main/preload.js @@ -1,5 +1,6 @@ const { contextBridge, ipcRenderer } = require('electron'); const path = require('path'); +const Logger = require('electron-log'); contextBridge.exposeInMainWorld('electron', { getConfigKey(key) { @@ -16,6 +17,12 @@ contextBridge.exposeInMainWorld('electron', { return () => ipcRenderer.removeListener(eventName, callback); }, + logger: { + info: (...message) => Logger.info(message), + error: (...message) => Logger.error(message), + warn: (...message) => Logger.warn(message), + }, + pathChanged(pathname) { ipcRenderer.send('path-changed', pathname); }, diff --git a/src/apps/main/remote-sync/RemoteSyncManager.ts b/src/apps/main/remote-sync/RemoteSyncManager.ts index cb130787c..7daf24b41 100644 --- a/src/apps/main/remote-sync/RemoteSyncManager.ts +++ b/src/apps/main/remote-sync/RemoteSyncManager.ts @@ -676,7 +676,7 @@ export class RemoteSyncManager { ); Logger.info( `Fetching item ${type} response: ${JSON.stringify( - response.data[0], + response.data?.length, null, 2 )}` @@ -700,7 +700,7 @@ export class RemoteSyncManager { ); Logger.info( `Fetching by folder ${type} by folder response: ${JSON.stringify( - response.data.result[0], + response.data.result?.length, null, 2 )}` diff --git a/src/apps/main/types.ts b/src/apps/main/types.ts index cab195049..8e06531c9 100644 --- a/src/apps/main/types.ts +++ b/src/apps/main/types.ts @@ -14,6 +14,7 @@ export type User = { registerCompleted: boolean; revocateKey: string; root_folder_id: number; + rootFolderId: string; sharedWorkspace: boolean; teams: boolean; userId: string; diff --git a/src/apps/sync-engine/dependency-injection/common/traverser.ts b/src/apps/sync-engine/dependency-injection/common/traverser.ts index be17a4e0c..f7b3017df 100644 --- a/src/apps/sync-engine/dependency-injection/common/traverser.ts +++ b/src/apps/sync-engine/dependency-injection/common/traverser.ts @@ -16,7 +16,8 @@ export class DependencyInjectionTraverserProvider { const traverser = Traverser.existingItems( crypt, ipcRendererSyncEngine, - user.root_folder_id + user.root_folder_id, + user.rootFolderId ); DependencyInjectionTraverserProvider.traverser = traverser; diff --git a/src/apps/sync-engine/dependency-injection/folders/builder.ts b/src/apps/sync-engine/dependency-injection/folders/builder.ts index f3cc0c4ee..7d7cbb933 100644 --- a/src/apps/sync-engine/dependency-injection/folders/builder.ts +++ b/src/apps/sync-engine/dependency-injection/folders/builder.ts @@ -17,7 +17,7 @@ import { RetrieveAllFolders } from '../../../../context/virtual-drive/folders/ap import { SynchronizeOfflineModifications } from '../../../../context/virtual-drive/folders/application/SynchronizeOfflineModifications'; import { SynchronizeOfflineModificationsOnFolderCreated } from '../../../../context/virtual-drive/folders/application/SynchronizeOfflineModificationsOnFolderCreated'; import { FolderPlaceholderUpdater } from '../../../../context/virtual-drive/folders/application/UpdatePlaceholderFolder'; -import { HttpRemoteFileSystem } from '../../../../context/virtual-drive/folders/infrastructure/HttpRemoteFileSystem'; +import { HttpRemoteFolderSystem } from '../../../../context/virtual-drive/folders/infrastructure/HttpRemoteFolderSystem'; import { InMemoryFolderRepository } from '../../../../context/virtual-drive/folders/infrastructure/InMemoryFolderRepository'; import { InMemoryOfflineFolderRepository } from '../../../../context/virtual-drive/folders/infrastructure/InMemoryOfflineFolderRepository'; import { ipcRendererSyncEngine } from '../../ipcRendererSyncEngine'; @@ -48,7 +48,7 @@ export async function buildFoldersContainer( virtualDrive, shredContainer.relativePathToAbsoluteConverter ); - const remoteFileSystem = new HttpRemoteFileSystem( + const remoteFolderSystem = new HttpRemoteFolderSystem( clients.drive, clients.newDrive ); @@ -67,7 +67,7 @@ export async function buildFoldersContainer( const folderDeleter = new FolderDeleter( repository, - remoteFileSystem, + remoteFolderSystem, localFileSystem, allParentFoldersStatusIsExists ); @@ -76,7 +76,7 @@ export async function buildFoldersContainer( const folderCreator = new FolderCreator( repository, - remoteFileSystem, + remoteFolderSystem, ipcRendererSyncEngine, eventBus, folderPlaceholderConverter @@ -84,12 +84,12 @@ export async function buildFoldersContainer( const folderMover = new FolderMover( repository, - remoteFileSystem, + remoteFolderSystem, folderFinder ); const folderRenamer = new FolderRenamer( repository, - remoteFileSystem, + remoteFolderSystem, ipcRendererSyncEngine ); @@ -144,7 +144,7 @@ export async function buildFoldersContainer( const folderPlaceholderDeleter = new FolderPlaceholderDeleter( shredContainer.relativePathToAbsoluteConverter, - remoteFileSystem, + remoteFolderSystem, localFileSystem ); diff --git a/src/apps/sync-engine/dependency-injection/items/builder.ts b/src/apps/sync-engine/dependency-injection/items/builder.ts index 20a7c7ffd..7be801d59 100644 --- a/src/apps/sync-engine/dependency-injection/items/builder.ts +++ b/src/apps/sync-engine/dependency-injection/items/builder.ts @@ -20,12 +20,14 @@ export function buildItemsContainer(): ItemsContainer { const existingItemsTraverser = Traverser.existingItems( nameDecryptor, ipcRendererSyncEngine, - user.root_folder_id + user.root_folder_id, + user.rootFolderId ); const allStatusesTraverser = Traverser.allItems( nameDecryptor, ipcRendererSyncEngine, - user.root_folder_id + user.root_folder_id, + user.rootFolderId ); const treeBuilder = new TreeBuilder( remoteItemsGenerator, diff --git a/src/context/shared/domain/ServerFolder.ts b/src/context/shared/domain/ServerFolder.ts index e1ca1ff35..7af7e6a7d 100644 --- a/src/context/shared/domain/ServerFolder.ts +++ b/src/context/shared/domain/ServerFolder.ts @@ -15,4 +15,5 @@ export type ServerFolder = { plain_name: string | null; status: ServerFolderStatus; uuid: string; + removed: boolean; }; diff --git a/src/context/virtual-drive/folders/application/FolderCreator.ts b/src/context/virtual-drive/folders/application/FolderCreator.ts index 0b64008dc..202a170a4 100644 --- a/src/context/virtual-drive/folders/application/FolderCreator.ts +++ b/src/context/virtual-drive/folders/application/FolderCreator.ts @@ -3,13 +3,13 @@ import { EventBus } from '../../shared/domain/EventBus'; import { Folder } from '../domain/Folder'; import { FolderRepository } from '../domain/FolderRepository'; import { OfflineFolder } from '../domain/OfflineFolder'; -import { RemoteFileSystem } from '../domain/file-systems/RemoteFileSystem'; +import { RemoteFolderSystem } from '../domain/file-systems/RemoteFolderSystem'; import { FolderPlaceholderConverter } from './FolderPlaceholderConverter'; export class FolderCreator { constructor( private readonly repository: FolderRepository, - private readonly remote: RemoteFileSystem, + private readonly remote: RemoteFolderSystem, private readonly ipc: SyncEngineIpc, private readonly eventBus: EventBus, private readonly folderPlaceholderConverter: FolderPlaceholderConverter diff --git a/src/context/virtual-drive/folders/application/FolderDeleter.ts b/src/context/virtual-drive/folders/application/FolderDeleter.ts index 2eede9b9e..3293e753a 100644 --- a/src/context/virtual-drive/folders/application/FolderDeleter.ts +++ b/src/context/virtual-drive/folders/application/FolderDeleter.ts @@ -4,7 +4,7 @@ import { ActionNotPermittedError } from '../domain/errors/ActionNotPermittedErro import { FolderNotFoundError } from '../domain/errors/FolderNotFoundError'; import { AllParentFoldersStatusIsExists } from './AllParentFoldersStatusIsExists'; import { FolderRepository } from '../domain/FolderRepository'; -import { RemoteFileSystem } from '../domain/file-systems/RemoteFileSystem'; +import { RemoteFileSystem } from '../domain/file-systems/RemoteFolderSystem'; import { LocalFolderSystem } from '../domain/file-systems/LocalFolderSystem'; export class FolderDeleter { diff --git a/src/context/virtual-drive/folders/application/FolderMover.ts b/src/context/virtual-drive/folders/application/FolderMover.ts index f185e9fd8..d0038b70d 100644 --- a/src/context/virtual-drive/folders/application/FolderMover.ts +++ b/src/context/virtual-drive/folders/application/FolderMover.ts @@ -3,7 +3,7 @@ import { FolderPath } from '../domain/FolderPath'; import { Folder } from '../domain/Folder'; import { FolderFinder } from './FolderFinder'; import { FolderRepository } from '../domain/FolderRepository'; -import { RemoteFileSystem } from '../domain/file-systems/RemoteFileSystem'; +import { RemoteFileSystem } from '../domain/file-systems/RemoteFolderSystem'; export class FolderMover { constructor( diff --git a/src/context/virtual-drive/folders/application/FolderPlaceholderDeleter.ts b/src/context/virtual-drive/folders/application/FolderPlaceholderDeleter.ts index 410ffb110..835ec297d 100644 --- a/src/context/virtual-drive/folders/application/FolderPlaceholderDeleter.ts +++ b/src/context/virtual-drive/folders/application/FolderPlaceholderDeleter.ts @@ -1,7 +1,7 @@ import { RelativePathToAbsoluteConverter } from '../../shared/application/RelativePathToAbsoluteConverter'; import { Folder } from '../domain/Folder'; import { FolderStatuses } from '../domain/FolderStatus'; -import { RemoteFileSystem } from '../domain/file-systems/RemoteFileSystem'; +import { RemoteFileSystem } from '../domain/file-systems/RemoteFolderSystem'; import { LocalFolderSystem } from '../domain/file-systems/LocalFolderSystem'; import Logger from 'electron-log'; import { sleep } from '../../../../apps/main/util'; diff --git a/src/context/virtual-drive/folders/application/FolderRenamer.ts b/src/context/virtual-drive/folders/application/FolderRenamer.ts index 8304e025c..ea4a198a9 100644 --- a/src/context/virtual-drive/folders/application/FolderRenamer.ts +++ b/src/context/virtual-drive/folders/application/FolderRenamer.ts @@ -1,7 +1,7 @@ import { FolderPath } from '../domain/FolderPath'; import { Folder } from '../domain/Folder'; import { FolderRepository } from '../domain/FolderRepository'; -import { RemoteFileSystem } from '../domain/file-systems/RemoteFileSystem'; +import { RemoteFileSystem } from '../domain/file-systems/RemoteFolderSystem'; import { SyncEngineIpc } from '../../../../apps/sync-engine/ipcRendererSyncEngine'; export class FolderRenamer { diff --git a/src/context/virtual-drive/folders/application/Offline/OfflineFolderCreator.ts b/src/context/virtual-drive/folders/application/Offline/OfflineFolderCreator.ts index 9bd900a35..458dd588a 100644 --- a/src/context/virtual-drive/folders/application/Offline/OfflineFolderCreator.ts +++ b/src/context/virtual-drive/folders/application/Offline/OfflineFolderCreator.ts @@ -1,3 +1,4 @@ +import Logger from 'electron-log'; import { FolderPath } from '../../domain/FolderPath'; import { OfflineFolder } from '../../domain/OfflineFolder'; import { OfflineFolderRepository } from '../../domain/OfflineFolderRepository'; @@ -26,7 +27,11 @@ export class OfflineFolderCreator { const parent = this.folderFinder.run(folderPath.dirname()); - const folder = OfflineFolder.create(folderPath, parent.id); + Logger.debug('[DEBUG IN OFFLINEFOLDERCREATOR STEEP 1]'); + + Logger.debug(parent); + + const folder = OfflineFolder.create(folderPath, parent.id, parent.uuid); this.offlineRepository.update(folder); diff --git a/src/context/virtual-drive/folders/domain/OfflineFolder.ts b/src/context/virtual-drive/folders/domain/OfflineFolder.ts index 3d72c4855..d923b794f 100644 --- a/src/context/virtual-drive/folders/domain/OfflineFolder.ts +++ b/src/context/virtual-drive/folders/domain/OfflineFolder.ts @@ -8,6 +8,7 @@ import { FolderRenamedDomainEvent } from './events/FolderRenamedDomainEvent'; export type OfflineFolderAttributes = { uuid: string; parentId: number; + parentUuid: string; path: string; updatedAt: string; createdAt: string; @@ -19,6 +20,7 @@ export class OfflineFolder extends AggregateRoot { private _uuid: FolderUuid, private _path: FolderPath, private _parentId: number, + private _parentUuid: FolderUuid, public createdAt: Date, public updatedAt: Date, private _status: FolderStatus @@ -50,6 +52,10 @@ export class OfflineFolder extends AggregateRoot { return this._parentId; } + public get parentUuid() { + return this._parentUuid.value; + } + public get status() { return this._status; } @@ -64,18 +70,27 @@ export class OfflineFolder extends AggregateRoot { new FolderUuid(attributes.uuid), new FolderPath(attributes.path), attributes.parentId, + attributes.parentUuid + ? new FolderUuid(attributes.parentUuid) + : FolderUuid.random(), new Date(attributes.updatedAt), new Date(attributes.createdAt), FolderStatus.fromValue(attributes.status) ); } - static create(path: FolderPath, parentId: number): OfflineFolder { + static create( + path: FolderPath, + parentId: number, + parentUuid: string + ): OfflineFolder { return new OfflineFolder( FolderUuid.random(), path, parentId, + new FolderUuid(parentUuid), new Date(), + new Date(), FolderStatus.Exists ); @@ -83,6 +98,7 @@ export class OfflineFolder extends AggregateRoot { moveTo(destinationFolder: Folder) { this._parentId = destinationFolder.id; + this._parentUuid = new FolderUuid(destinationFolder.uuid); } rename(destination: FolderPath) { @@ -116,6 +132,7 @@ export class OfflineFolder extends AggregateRoot { const attributes: OfflineFolderAttributes = { uuid: this.uuid, parentId: this._parentId, + parentUuid: this._parentUuid.value, path: this._path.value, updatedAt: this.updatedAt.toISOString(), createdAt: this.createdAt.toISOString(), diff --git a/src/context/virtual-drive/folders/domain/file-systems/RemoteFileSystem.ts b/src/context/virtual-drive/folders/domain/file-systems/RemoteFolderSystem.ts similarity index 91% rename from src/context/virtual-drive/folders/domain/file-systems/RemoteFileSystem.ts rename to src/context/virtual-drive/folders/domain/file-systems/RemoteFolderSystem.ts index 613a1d87e..e5cf78417 100644 --- a/src/context/virtual-drive/folders/domain/file-systems/RemoteFileSystem.ts +++ b/src/context/virtual-drive/folders/domain/file-systems/RemoteFolderSystem.ts @@ -2,7 +2,7 @@ import { Folder, FolderAttributes } from '../Folder'; import { FolderStatuses } from '../FolderStatus'; import { OfflineFolder } from '../OfflineFolder'; -export interface RemoteFileSystem { +export interface RemoteFolderSystem { persist(offline: OfflineFolder): Promise; trash(id: Folder['id']): Promise; diff --git a/src/context/virtual-drive/folders/infrastructure/HttpRemoteFileSystem.ts b/src/context/virtual-drive/folders/infrastructure/HttpRemoteFolderSystem.ts similarity index 72% rename from src/context/virtual-drive/folders/infrastructure/HttpRemoteFileSystem.ts rename to src/context/virtual-drive/folders/infrastructure/HttpRemoteFolderSystem.ts index ece8186c6..1e350c13d 100644 --- a/src/context/virtual-drive/folders/infrastructure/HttpRemoteFileSystem.ts +++ b/src/context/virtual-drive/folders/infrastructure/HttpRemoteFolderSystem.ts @@ -4,13 +4,13 @@ import * as uuid from 'uuid'; import { Folder, FolderAttributes } from '../domain/Folder'; import { FolderStatuses } from '../domain/FolderStatus'; import { UpdateFolderNameDTO } from './dtos/UpdateFolderNameDTO'; -import { RemoteFileSystem } from '../domain/file-systems/RemoteFileSystem'; +import { RemoteFolderSystem } from '../domain/file-systems/RemoteFolderSystem'; import { OfflineFolder } from '../domain/OfflineFolder'; import { ServerFolder } from '../../../shared/domain/ServerFolder'; import { CreateFolderDTO } from './dtos/CreateFolderDTO'; import * as Sentry from '@sentry/electron/renderer'; -export class HttpRemoteFileSystem implements RemoteFileSystem { +export class HttpRemoteFolderSystem implements RemoteFolderSystem { public folders: Record = {}; constructor( @@ -57,7 +57,47 @@ export class HttpRemoteFileSystem implements RemoteFileSystem { Sentry.captureException(error); if (axios.isAxiosError(error)) { Logger.error('[Is Axios Error]', error.response?.data); + const existing = await this.existFolder(offline); + return existing.status !== FolderStatuses.EXISTS + ? Promise.reject(error) + : existing; } + + throw error; + } + } + + private async existFolder(offline: OfflineFolder): Promise { + try { + const response = await this.trashClient.get( + `${process.env.NEW_DRIVE_URL}/drive/folders/content/${offline.parentUuid}/folders/existence?plainName=${offline.basename}` + ); + Logger.debug('[FOLDER FILE SYSTEM] Folder already exists', response.data); + + const serverFolder = response.data + .existentFolders[0] as ServerFolder | null; + + if (!serverFolder) { + throw new Error('Folder creation failed, no data returned'); + } + return { + id: serverFolder.id, + uuid: serverFolder.uuid, + parentId: serverFolder.parentId, + updatedAt: serverFolder.updatedAt, + createdAt: serverFolder.createdAt, + path: offline.path.value, + status: serverFolder.removed + ? FolderStatuses.TRASHED + : FolderStatuses.EXISTS, + }; + } catch (error) { + Logger.error('[FOLDER FILE SYSTEM] Error creating folder'); + Sentry.captureException(error); + if (axios.isAxiosError(error)) { + Logger.error('[Is Axios Error]', error.response?.data); + } + throw error; } } diff --git a/src/context/virtual-drive/items/application/Traverser.ts b/src/context/virtual-drive/items/application/Traverser.ts index f8beb3a00..f06927eda 100644 --- a/src/context/virtual-drive/items/application/Traverser.ts +++ b/src/context/virtual-drive/items/application/Traverser.ts @@ -29,6 +29,7 @@ export class Traverser { private readonly decrypt: NameDecrypt, private readonly ipc: SyncEngineIpc, private readonly baseFolderId: number, + private readonly baseFolderUuid: string, private fileStatusesToFilter: Array, private folderStatusesToFilter: Array ) {} @@ -36,12 +37,14 @@ export class Traverser { static existingItems( decrypt: NameDecrypt, ipc: SyncEngineIpc, - baseFolderId: number + baseFolderId: number, + baseFolderUuid: string ): Traverser { return new Traverser( decrypt, ipc, baseFolderId, + baseFolderUuid, [ServerFileStatus.EXISTS], [ServerFolderStatus.EXISTS] ); @@ -50,9 +53,10 @@ export class Traverser { static allItems( decrypt: NameDecrypt, ipc: SyncEngineIpc, - baseFolderId: number + baseFolderId: number, + baseFolderUuid: string ): Traverser { - return new Traverser(decrypt, ipc, baseFolderId, [], []); + return new Traverser(decrypt, ipc, baseFolderId, baseFolderUuid, [], []); } public setFileStatusesToFilter(statuses: Array): void { @@ -64,11 +68,9 @@ export class Traverser { } private createRootFolder(): Folder { - const rootFolderUuid = '43711926-15c2-5ebf-8c24-5099fa9af3c3'; - return Folder.from({ id: this.baseFolderId, - uuid: rootFolderUuid, + uuid: this.baseFolderUuid, parentId: null, updatedAt: new Date().toISOString(), createdAt: new Date().toISOString(), diff --git a/tests/context/virtual-drive/folders/__mocks__/FolderRemoteFileSystemMock.ts b/tests/context/virtual-drive/folders/__mocks__/FolderRemoteFileSystemMock.ts index 4a43211c3..0549e6b1a 100644 --- a/tests/context/virtual-drive/folders/__mocks__/FolderRemoteFileSystemMock.ts +++ b/tests/context/virtual-drive/folders/__mocks__/FolderRemoteFileSystemMock.ts @@ -3,7 +3,7 @@ import { FolderAttributes, } from '../../../../../src/context/virtual-drive/folders/domain/Folder'; import { OfflineFolder } from '../../../../../src/context/virtual-drive/folders/domain/OfflineFolder'; -import { RemoteFileSystem } from '../../../../../src/context/virtual-drive/folders/domain/file-systems/RemoteFileSystem'; +import { RemoteFileSystem } from '../../../../../src/context/virtual-drive/folders/domain/file-systems/RemoteFolderSystem'; export class FolderRemoteFileSystemMock implements RemoteFileSystem { public readonly persistMock = jest.fn();