Skip to content

Commit

Permalink
feat(backup): Remove old dedup mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
zatteo committed Jan 10, 2024
1 parent 7429dfd commit 2f382cf
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 124 deletions.
8 changes: 1 addition & 7 deletions src/app/domain/backup/services/manageBackup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import {
setBackupAsRunning,
setBackupAsDone,
setLastBackup,
fixLocalBackupConfigIfNecessary,
addRemoteDuplicatesToBackupedMedias
fixLocalBackupConfigIfNecessary
} from '/app/domain/backup/services/manageLocalBackupConfig'
import { prepareDeduplication } from '/app/domain/backup/services/manageRemoteBackupConfig'
import { getMediasToBackup } from '/app/domain/backup/services/getMedias'
Expand Down Expand Up @@ -260,10 +259,5 @@ const initializeBackup = async (
throw e
}

if (flag('flagship.backup.dedup')) {
await addRemoteDuplicatesToBackupedMedias(client)
localBackupConfig = await getLocalBackupConfig(client)
}

return localBackupConfig
}
82 changes: 0 additions & 82 deletions src/app/domain/backup/services/manageLocalBackupConfig.spec.ts

This file was deleted.

25 changes: 0 additions & 25 deletions src/app/domain/backup/services/manageLocalBackupConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,28 +317,3 @@ export const setLastBackup = async (

log.debug('Last backup set')
}

export const addRemoteDuplicatesToBackupedMedias = async (
client: CozyClient
): Promise<void> => {
log.debug('Trying to find remote duplicates')

const localBackupConfig = await getLocalBackupConfig(client)

const remoteDuplicates = await fetchBackupedMedias(client)

const remoteDuplicatesNotAlreadyConsideredAsBackuped =
remoteDuplicates.filter(
m => !localBackupConfig.backupedMedias.find(a => isSameMedia(a, m))
)

log.debug(
`${remoteDuplicatesNotAlreadyConsideredAsBackuped.length} medias found remotely that are present locally but not in local backuped medias`
)

localBackupConfig.backupedMedias = localBackupConfig.backupedMedias.concat(
remoteDuplicatesNotAlreadyConsideredAsBackuped
)

await setLocalBackupConfig(client, localBackupConfig)
}
12 changes: 2 additions & 10 deletions src/app/domain/backup/services/manageRemoteBackupConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,17 +372,9 @@ export const fetchBackupedMedias = async (

const allMedias = await getAllMedias(client)

let data
const filesQuery = buildFilesQuery(deviceId)

if (flag('flagship.backup.dedup')) {
const filesQuery = buildAllMediasFilesQuery()

data = (await client.queryAll(filesQuery)) as FilesQueryAllResult
} else {
const filesQuery = buildFilesQuery(deviceId)

data = (await client.queryAll(filesQuery)) as FilesQueryAllResult
}
const data = (await client.queryAll(filesQuery)) as FilesQueryAllResult

const backupedMedias = filterMediasAlreadyBackuped(allMedias, data)

Expand Down

0 comments on commit 2f382cf

Please sign in to comment.