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

Restore missed original file from the latest version #6483

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

yurabakhtin
Copy link
Contributor

What kind of change does this PR introduce? (check at least one)

  • Bugfix

The PR fulfills these requirements:

  • All tests are passing
  • Changelog was modified

Other information:
Issue: https://github.com/humhub/humhub-internal/issues/96

@yurabakhtin yurabakhtin requested a review from luke- August 4, 2023 10:12
@yurabakhtin
Copy link
Contributor Author

yurabakhtin commented Aug 4, 2023

I see the problem is that original file with name file is missed but a version file like old-123 exists, so I would suggest a solution from this PR #6483, I have done to restore the file from the latest version file old-123 if it exists


maybe it is not good for performance to run the file_exists($originalFilePath) here https://github.com/humhub/humhub/pull/6483/files#diff-2f3a5cf58d46a6971793c97d7c4defb317661fce7c7cb141d28467442049dbf9R76 on each call the File->store->get(null)

I added the checking there because it is called here https://github.com/humhub/humhub/blob/master/protected/humhub/modules/file/actions/DownloadAction.php#L189-L194:

        if (!file_exists($this->file->store->get($this->variant))) {
            throw new HttpException(404, Yii::t('FileModule.base', 'Could not find requested file!'));
        }

I think it must be modified to if (!$this->file->store->has($this->variant)) and then we could run new StorageManager->restoreMissedOriginalFile() only inside the StorageManager->has($variant = null)
I have implemented this in next commit 2b47ac9.

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.

None yet

1 participant