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

Return correct status if touch failed #41062

Merged
merged 1 commit into from
Oct 24, 2023

Conversation

artonge
Copy link
Contributor

@artonge artonge commented Oct 23, 2023

When uploading a file to an external s3 bucket, the original mtime is not kept. It boils down to the touch operation being deactivated for existing file for s3 buckets. Limitation introduced here: #21734

This PR changes the return value of the touch method. Now this method returns false when the file already exists to trigger the following condition:

if (!$result) {
// If create file fails because of permissions on external storage like SMB folders,
// check file exists and return false if not.
if (!$this->file_exists($path)) {
return false;
}
if (is_null($mtime)) {
$mtime = time();
}
//if native touch fails, we emulate it by changing the mtime in the cache
$this->putFileInfo($path, ['mtime' => floor($mtime)]);
}

Signed-off-by: Louis Chemineau <louis@chmn.me>
@artonge artonge self-assigned this Oct 23, 2023
@artonge artonge added this to the Nextcloud 28 milestone Oct 23, 2023
@artonge artonge added 3. to review Waiting for reviews feature: files php Pull requests that update Php code feature: object storage labels Oct 23, 2023
@artonge artonge requested a review from icewind1991 October 23, 2023 16:01
@artonge artonge requested review from a team, Altahrim and nfebe and removed request for a team October 24, 2023 14:08
@artonge
Copy link
Contributor Author

artonge commented Oct 24, 2023

CI failure is unrelated

@artonge artonge merged commit c5d8240 into master Oct 24, 2023
51 checks passed
@artonge artonge deleted the artonge/fix/return_fals_if_touch_fails branch October 24, 2023 16:08
@artonge
Copy link
Contributor Author

artonge commented Nov 2, 2023

/backport to stable27

@artonge
Copy link
Contributor Author

artonge commented Nov 2, 2023

/backport to stable26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews feature: files feature: object storage php Pull requests that update Php code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants