Skip to content

fix(trashbin): Truncate long filenames - #38355

Merged
blizzz merged 1 commit into
masterfrom
fix/trashbin-long-filenames
Jun 1, 2023
Merged

fix(trashbin): Truncate long filenames#38355
blizzz merged 1 commit into
masterfrom
fix/trashbin-long-filenames

Conversation

@Pytal

@PytalPytal commented May 17, 2023

Copy link
Copy Markdown
Member

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

@PytalPytal added this to the Nextcloud 28 milestone May 17, 2023
@PytalPytal self-assigned this May 17, 2023
self::copy($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $owner . '/files_trashbin/versions/' . static::getTrashFilename($v['name'] . '.v' . $v['version'], $timestamp));
}
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
Comment threadapps/files_trashbin/lib/Trash/LegacyTrashBackend.php Fixed
Comment threadapps/files_trashbin/lib/Trash/LegacyTrashBackend.php Fixed
self::copy_recursive($owner . '/files_versions/' . $ownerPath, $owner . '/files_trashbin/versions/' . static::getTrashFilename(basename($ownerPath), $timestamp), $rootView);
}
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
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
Copy Markdown
Contributor

@Pytal why not increase the table lenght instead?

@Pytal

Copy link
Copy Markdown
MemberAuthor

@Pytal why not increase the table lenght instead?

Common file system limits 🤷‍♂️

@icewind1991

Copy link
Copy Markdown
Member

Looks good but could really use some tests

Comment threadapps/files_trashbin/lib/Trash/LegacyTrashBackend.php Outdated
Comment threadapps/files_trashbin/lib/Trash/LegacyTrashBackend.php Fixed
@Pytal
Pytalforce-pushed the fix/trashbin-long-filenames branch from 8e0cf8a to f51f9abCompareMay 26, 2023 02:17
@Pytal
Pytal requested a review from come-ncMay 26, 2023 02:19
@Pytal
Pytalforce-pushed the fix/trashbin-long-filenames branch from f51f9ab to 0a1fe5cCompareMay 31, 2023 23:55
Signed-off-by: Christopher Ng <chrng8@gmail.com>
@Pytal
Pytalforce-pushed the fix/trashbin-long-filenames branch from 0a1fe5c to 7c430a8CompareJune 1, 2023 02:06
@Pytal

Pytal commented Jun 1, 2023

Copy link
Copy Markdown
MemberAuthor

Fixed tests!

@blizzz

Copy link
Copy Markdown
Member

/backport to stable27

@blizzz

Copy link
Copy Markdown
Member

/backport to stable26

@blizzz

Copy link
Copy Markdown
Member

/backport to stable25

@blizzz

Copy link
Copy Markdown
Member

/backport to stable24

@blizzz

Copy link
Copy Markdown
Member

/backport to stable20

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

Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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
Copy Markdown
Member

/backport to stable25

@Pytal

Pytal commented Jun 1, 2023

Copy link
Copy Markdown
MemberAuthor

/backport to stable24

@Pytal

Pytal commented Jun 1, 2023

Copy link
Copy Markdown
MemberAuthor

/backport to stable20

@backportbot-nextcloud

Copy link
Copy Markdown

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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@Pytal@szaimen@icewind1991@blizzz@solracsf@github-advanced-security@come-nc