Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Enforce Stack queries when doing backup #1269

Merged
merged 2 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@
"@sentry/integrations": "7.114.0",
"@sentry/react-native": "5.33.1",
"base-64": "^1.0.0",
"cozy-client": "^51.7.0",
"cozy-client": "^52.0.0",
"cozy-clisk": "^0.38.1",
"cozy-device-helper": "^2.7.0",
"cozy-flags": "^3.2.0",
"cozy-intent": "^2.23.0",
"cozy-logger": "^1.10.0",
"cozy-minilog": "3.3.1",
"cozy-pouch-link": "^51.7.0",
"cozy-pouch-link": "^52.0.0",
"date-fns": "2.29.3",
"events": "^3.3.0",
"html-entities": "^2.3.3",
Expand Down
6 changes: 5 additions & 1 deletion src/app/domain/backup/services/manageLocalBackupConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
uri: media.uri,
creationDate: media.creationDate,
modificationDate: media.modificationDate,
remoteId: documentCreated.id!,

Check warning on line 146 in src/app/domain/backup/services/manageLocalBackupConfig.ts

View workflow job for this annotation

GitHub Actions / Quality Checks

Forbidden non-null assertion
md5: documentCreated.attributes.md5sum
}

Expand Down Expand Up @@ -205,11 +205,15 @@
const fileQuery = buildFileQuery(
localBackupConfig.remoteBackupConfig.backupFolder.id
)
const fileQueryOptions = { forceStack: true }

let remoteBackupFolderUpdated

try {
const { data } = (await client.query(fileQuery)) as FileCollectionGetResult
const { data } = (await client.query(
fileQuery,
fileQueryOptions
)) as FileCollectionGetResult

remoteBackupFolderUpdated = data
} catch (e) {
Expand Down
16 changes: 13 additions & 3 deletions src/app/domain/backup/services/manageRemoteBackupConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,11 @@ export const createRemoteBackupFolder = async (
)

const fileQuery = buildFileQuery(backupFolderId)
const fileQueryOptions = { forceStack: true }

const { data: backupFolder } = (await client.query(
fileQuery
fileQuery,
fileQueryOptions
)) as FileCollectionGetResult

const remoteBackupConfig = {
Expand Down Expand Up @@ -331,8 +333,12 @@ export const getRemoteFiles = (): File[] => {

const fetchAllRemoteFiles = async (client: CozyClient): Promise<File[]> => {
const filesQuery = buildAllMediasFilesQuery()
const fileQueryOptions = { forceStack: true }

const remoteFiles = (await client.queryAll(filesQuery)) as FilesQueryAllResult
const remoteFiles = (await client.queryAll(
filesQuery,
fileQueryOptions
)) as FilesQueryAllResult

const remoteFilesNotInTrash = remoteFiles.filter(
file => !isInTrash(file.path)
Expand Down Expand Up @@ -372,7 +378,11 @@ export const fetchBackupedMedias = async (

const filesQuery = buildFilesQuery(deviceId)

const data = (await client.queryAll(filesQuery)) as FilesQueryAllResult
const filesQueryOption = { forceStack: true }
const data = (await client.queryAll(
filesQuery,
filesQueryOption
)) as FilesQueryAllResult

const backupedMedias = filterMediasAlreadyBackuped(allMedias, data)

Expand Down
28 changes: 14 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8683,16 +8683,16 @@ cosmiconfig@^8.1.3:
parse-json "^5.2.0"
path-type "^4.0.0"

cozy-client@^51.7.0:
version "51.7.0"
resolved "https://registry.yarnpkg.com/cozy-client/-/cozy-client-51.7.0.tgz#c06393a9e13a6f2f2abcdf7cd1e4236a3e20588f"
integrity sha512-PffTajP04alPRrrWhuOdcmbqpV71nk7KQk+WkWCKXPbbjGU8NBcpLtJLLK/0IaI74DTiT0MSnwtl7fp+m0fR9w==
cozy-client@^52.0.0:
version "52.0.0"
resolved "https://registry.yarnpkg.com/cozy-client/-/cozy-client-52.0.0.tgz#bedbdee24846b8cc24cd4966ec8d19dd9661c872"
integrity sha512-WRjutF8NYRjNttllxPW0w94SSwNorJuWlZrsfjNshezMPGfK8eCGTC4Kyreo21dIbg3v4yRahlIKAqdvmBlNWw==
dependencies:
"@cozy/minilog" "1.0.0"
"@types/jest" "^26.0.20"
"@types/lodash" "^4.14.170"
btoa "^1.2.1"
cozy-stack-client "^51.6.0"
cozy-stack-client "^52.0.0"
date-fns "2.29.3"
json-stable-stringify "^1.0.1"
lodash "^4.17.13"
Expand Down Expand Up @@ -8759,19 +8759,19 @@ [email protected], cozy-minilog@^3.3.1:
dependencies:
microee "0.0.6"

cozy-pouch-link@^51.7.0:
version "51.7.0"
resolved "https://registry.yarnpkg.com/cozy-pouch-link/-/cozy-pouch-link-51.7.0.tgz#667c6c6d466fd51c89779f853ad174483e3cb57a"
integrity sha512-XSQzTWznD0YS7BFaYv3P7lCKbQb2//KILVZD+urR7IhzqzHkEr3jJux8RdaNLm2gdxvC8CQvRsoxG1v54W5sYg==
cozy-pouch-link@^52.0.0:
version "52.0.0"
resolved "https://registry.yarnpkg.com/cozy-pouch-link/-/cozy-pouch-link-52.0.0.tgz#c3dac6497ecc1af6827657a20072f03d99c3e7e9"
integrity sha512-/pEDlkgxx9R2RuThRboohTAXLLwz/uFqLWfUynne3BhvpIAZ3pupOElJfcSHhMJbbIxY4iIiJvZZWkl8TYBvRQ==
dependencies:
cozy-client "^51.7.0"
cozy-client "^52.0.0"
pouchdb-browser "^7.2.2"
pouchdb-find "^7.2.2"

cozy-stack-client@^51.6.0:
version "51.6.0"
resolved "https://registry.yarnpkg.com/cozy-stack-client/-/cozy-stack-client-51.6.0.tgz#bd81605bdd1e68161d1143856f78bca969086575"
integrity sha512-MRBTKtBtQ6jnmS4ij+nYjgeOecSNr9Z9kCNDlKW9884JxnI4VGfpq1w+ihN3EVh3EyqD98vnaQZ8VuYr6czeVQ==
cozy-stack-client@^52.0.0:
version "52.0.0"
resolved "https://registry.yarnpkg.com/cozy-stack-client/-/cozy-stack-client-52.0.0.tgz#b146997637facc8de55033a84fd7e4b30ea4533d"
integrity sha512-rJOUp7jcnIBEaL48+HVRF24IzYgNJYh2KLpkKFKfaNhO6oz/+dwW1VfETAKWldtNk1hMcFapbQIN58CqhGkIzA==
dependencies:
detect-node "^2.0.4"
mime "^2.4.0"
Expand Down
Loading