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

feat: Allow cozy-apps to access files offline #1237

Open
wants to merge 3 commits into
base: feat/open_offline
Choose a base branch
from

Conversation

Ldoppea
Copy link
Member

@Ldoppea Ldoppea commented Aug 26, 2024

When the application is offline, we want the user to be able to access their files that are accessible offline

To make this possible, we want the Flagship app to provide a new downloadFileAndPreview() interface that can be called from cozy-apps

Internally this method should allow to download and preview files, but also to store them in the device's storage in order to make them accessible later even when the app is offline

This method will be called from cozy-client through file model

For now we make files accessible only if they have already downloaded
once


We also want the user's important files to always be accessible offline

To make this possible, we want the app to download them in background on startup

We consider important files as files from mespapiers with specific qualification labels like passport, identification papers, vehicle registration, etc.


Finally, as we store offline accessible files in the device's storage, we want to prevent them to fill the entire device's storage

We chose to keep only files that were accessed in the previous month. All other files would be deleted

Important files are never deleted as long as they exist on the Cozy instance


TODO:

setDownloadProgress?.(progressPercent)
},
progressInterval: 100
}).promise
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe extract the download logic like we did for the upload ? https://github.com/cozy/cozy-flagship-app/tree/master/src/app/domain/upload/services


if (files.has(fileId)) {
return files.get(fileId)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the .has() ? .get() returns undefined if it does not exists.

log.debug(
`Remove old unimportant file ${
offlineFile.id
} (last opened on ${lastOpened.toString()})`
Copy link
Contributor

@zatteo zatteo Sep 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a risk to have an error here if lastOpened is undefined ? Seems no, I read the code below

When the application is offline, we want the user to be able to access
their files that are accessible offline

To make this possible, we want the Flagship app to provide a new
`downloadFileAndPreview()` interface that can be called from cozy-apps

Internally this method should allow to download and preview files, but
also to store them in the device's storage in order to make them
accessible later even when the app is offline

This method will be called from cozy-client through `file` model

For now we make files accessible only if they have already downloaded
once

In the following commit we will make important files accessible in a
proactive way
We want the user's important files to always be accessible offline

To make this possible, we want the app to download them in background
on startup

We consider important files as files from `mespapiers` with specific
qualification labels like passport, identification papers, vehicle
registration, etc.
As we store offline accessible files in the device's storage, we want
to prevent them to fill the entire device's storage

We chose to keep only files that were accessed in the previous month.
All other files would be deleted

Important files are never deleted as long as they exist on the Cozy
instance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants