nextcloud / integration_dropbox

🧊 Dropbox integration into Nextcloud
GNU Affero General Public License v3.0
26 stars 10 forks source link

Sync stop when server restart and user cannot start it back. #14

Closed leviia closed 1 year ago

leviia commented 3 years ago

Hello

First of all thanks for this great app.

There is an issue witch may also exist on integration_google and integration_onedrive.

When you star a sync everything goes well and those config variable are set

dropbox_import_running: 1
importing_dropbox: 1

The issue appear when you restart the server. Here you can go into a broken state where those two variable are set but nothing is currently running

dropbox_import_running: 1
importing_dropbox: 1

And it get worse, because even if the user stop the importation, only importing_dropbox is cleared as you can see in this code

        onCancelDropboxImport() {
            this.importingDropbox = false
            clearInterval(this.dropboxImportLoop)
            const req = {
                values: {
                    importing_dropbox: '0',
                    last_dropbox_import_timestamp: '0',
                    nb_imported_files: '0',
                },
            }

On file src/components/PersonalSettings.vue

So even if a user stop and restart the transfer, it is still stuck because the variable dropbox_import_running is never cleared (it is still equals to 1 even if nothing is running)

Then when user restart the importation this code is fired

    public function importDropboxJob(string $userId): void {
        $this->logger->error('Importing dropbox files for ' . $userId);

        // in case SSE is enabled
        $this->userScopeService->setUserScope($userId);
        $this->userScopeService->setFilesystemScope($userId);

        $importingDropbox = $this->config->getUserValue($userId, Application::APP_ID, 'importing_dropbox', '0') === '1';
        $jobRunning = $this->config->getUserValue($userId, Application::APP_ID, 'dropbox_import_running', '0') === '1';
        if (!$importingDropbox || $jobRunning) {
            return;
        }

on file lib/Service/DropboxStorageAPIService.php

As you can see we directly go to return and it just stop. So the user will never be able to start it back by himself. A manual intervention of the administrator is mandatory to clear this variable:

occ user:setting $user integration_dropbox dropbox_import_running 0

And then allow the user to start it back by himself. And this has to be made for every user at every reboot ! this is not ideal.

What I propose is

Please tell me if you think it is a good idea and if you would like to implement it on mainline so we will all benefit from it. As I said maybe integration_google and integration_onedrive have the same issue.

All the best

Arnaud

julien-nc commented 1 year ago

Hey, sorry for the infinitely late response :sweat:.

There is unfortunately no such thing as a temporary variable :grin:.

The solution I implemented for all OneDrive, Google and Dropbox data migration apps is to have a 1h timeout on the import jobs. This way one can start importing again after an hour if the job was brutally interrupted.

This will be included in all apps next releases. Feel free to reopen if needed.