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(trashbin): Truncate long filenames #38355

Merged
merged 1 commit into from
Jun 1, 2023
Merged

Conversation

Pytal
Copy link
Member

@Pytal Pytal commented May 17, 2023

Summary

Truncate filenames longer than the 250 char limit of the oc_filecache name column to fix deletion of files with names that would exceed 250 chars when appended with the 12 char timestamp suffix

Characters are removed from the middle of the string rather than the end due to dependencies on the embedded timestamp string which if truncated would throw trashbin errors

TODO

  • Tests

Checklist

@Pytal Pytal added this to the Nextcloud 28 milestone May 17, 2023
@Pytal Pytal requested review from icewind1991, blizzz and come-nc May 17, 2023 23:25
@Pytal Pytal self-assigned this May 17, 2023
}
self::move($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $user . '/files_trashbin/versions/' . $filename . '.v' . $v['version'] . '.d' . $timestamp);
self::move($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $user . '/files_trashbin/versions/' . static::getTrashFilename($filename . '.v' . $v['version'], $timestamp));

Check notice

Code scanning / Psalm

PossiblyFalseOperand

Cannot concatenate with a possibly false false|string
}
self::move($rootView, $owner . '/files_versions/' . $ownerPath, $user . '/files_trashbin/versions/' . $filename . '.d' . $timestamp);
self::move($rootView, $owner . '/files_versions/' . $ownerPath, $user . '/files_trashbin/versions/' . static::getTrashFilename($filename, $timestamp));

Check notice

Code scanning / Psalm

PossiblyFalseOperand

Cannot concatenate with a possibly false false|string
@@ -561,7 +562,7 @@
} elseif ($versions = self::getVersionsFromTrash($versionedFile, $timestamp, $user)) {
foreach ($versions as $v) {
if ($timestamp) {
$rootView->rename($user . '/files_trashbin/versions/' . $versionedFile . '.v' . $v . '.d' . $timestamp, $owner . '/files_versions/' . $ownerPath . '.v' . $v);
$rootView->rename($user . '/files_trashbin/versions/' . static::getTrashFilename($versionedFile . '.v' . $v, $timestamp), $owner . '/files_versions/' . $ownerPath . '.v' . $v);

Check notice

Code scanning / Psalm

PossiblyFalseOperand

Cannot concatenate with a possibly false false|string
@szaimen
Copy link
Contributor

szaimen commented May 18, 2023

@Pytal why not increase the table lenght instead?

@Pytal
Copy link
Member Author

Pytal commented May 18, 2023

@Pytal why not increase the table lenght instead?

Common file system limits 🤷‍♂️

@icewind1991
Copy link
Member

Looks good but could really use some tests

@Pytal Pytal force-pushed the fix/trashbin-long-filenames branch from 8e0cf8a to f51f9ab Compare May 26, 2023 02:17
@Pytal Pytal requested a review from come-nc May 26, 2023 02:19
@Pytal Pytal force-pushed the fix/trashbin-long-filenames branch from f51f9ab to 0a1fe5c Compare May 31, 2023 23:55
Signed-off-by: Christopher Ng <chrng8@gmail.com>
@Pytal Pytal force-pushed the fix/trashbin-long-filenames branch from 0a1fe5c to 7c430a8 Compare June 1, 2023 02:06
@Pytal
Copy link
Member Author

Pytal commented Jun 1, 2023

Fixed tests!

@blizzz
Copy link
Member

blizzz commented Jun 1, 2023

/backport to stable27

@blizzz
Copy link
Member

blizzz commented Jun 1, 2023

/backport to stable26

@blizzz
Copy link
Member

blizzz commented Jun 1, 2023

/backport to stable25

@blizzz
Copy link
Member

blizzz commented Jun 1, 2023

/backport to stable24

@blizzz
Copy link
Member

blizzz commented Jun 1, 2023

/backport to stable20

@blizzz blizzz merged commit 2be74ee into master Jun 1, 2023
@blizzz blizzz deleted the fix/trashbin-long-filenames branch June 1, 2023 09:30
@backportbot-nextcloud
Copy link

The backport to stable25 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable25
git pull origin/stable25

# Create the new backport branch
git checkout -b fix/foo-stable25

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts. Resolve them.
git cherry-pick abc123

# Push the cherry pick commit to the remote repository and open a pull request
git push origin fix/foo-stable25

More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport

@backportbot-nextcloud
Copy link

The backport to stable24 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable24
git pull origin/stable24

# Create the new backport branch
git checkout -b fix/foo-stable24

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts. Resolve them.
git cherry-pick abc123

# Push the cherry pick commit to the remote repository and open a pull request
git push origin fix/foo-stable24

More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport

@backportbot-nextcloud
Copy link

The backport to stable20 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable20
git pull origin/stable20

# Create the new backport branch
git checkout -b fix/foo-stable20

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts. Resolve them.
git cherry-pick abc123

# Push the cherry pick commit to the remote repository and open a pull request
git push origin fix/foo-stable20

More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport

@solracsf
Copy link
Member

solracsf commented Jun 1, 2023

/backport to stable25

@Pytal
Copy link
Member Author

Pytal commented Jun 1, 2023

/backport to stable24

@Pytal
Copy link
Member Author

Pytal commented Jun 1, 2023

/backport to stable20

@backportbot-nextcloud
Copy link

The backport to stable20 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable20
git pull origin/stable20

# Create the new backport branch
git checkout -b fix/foo-stable20

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts. Resolve them.
git cherry-pick abc123

# Push the cherry pick commit to the remote repository and open a pull request
git push origin fix/foo-stable20

More info at https://docs.nextcloud.com/server/latest/developer_manual/getting_started/development_process.html#manual-backport

mejo- added a commit to nextcloud/collectives that referenced this pull request Jun 5, 2023
See nextcloud/server#38355 for further context.

Signed-off-by: Jonas <jonas@freesources.org>
mejo- added a commit to nextcloud/collectives that referenced this pull request Jun 5, 2023
See nextcloud/server#38355 for further context.

Signed-off-by: Jonas <jonas@freesources.org>
mejo- added a commit to nextcloud/collectives that referenced this pull request Jun 5, 2023
See nextcloud/server#38355 for further context.

Signed-off-by: Jonas <jonas@freesources.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants