Skip to content

Commit

Permalink
Retain permissions when copy/pasting
Browse files Browse the repository at this point in the history
When copy pasting pass the `--archive` flag to `cp` so permissions,
timestamps are retained.
  • Loading branch information
jelly committed May 29, 2024
1 parent d617825 commit d717557
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/fileActions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,8 @@ export const fileActions = (path, selected, setSelected, clipboard, setClipboard
}
cockpit.spawn([
"cp",
"-R",
"--archive",
"--recursive",
...sourcePaths,
targetPath
]).catch(err => addAlert(err.message, "danger", new Date().getTime()));
Expand Down
20 changes: 20 additions & 0 deletions test/check-application
Original file line number Diff line number Diff line change
Expand Up @@ -947,9 +947,29 @@ class TestFiles(testlib.MachineCase):
b.click("#paste-item")
b.wait_visible("[data-item='newfile']")
b.wait_in_text("h4.pf-v5-c-alert__title", "Paste not overwriting existing files")
b.click(".pf-v5-c-alert__action button")
b.wait_not_present(".pf-v5-c-alert__action")
b.click(".breadcrumb-button:nth-of-type(4)")
self.browser.wait_not_present(".pf-c-empty-state")

# Copy as user should retain permissions
m.execute("runuser -u admin echo 'text' > /home/admin/permissions.txt")
m.execute("chmod 600 /home/admin/permissions.txt; chown admin:users /home/admin/permissions.txt")
m.execute("runuser -u admin mkdir /home/admin/destDir")

b.click("[data-item='permissions.txt']")
b.click("#dropdown-menu")
b.click("#copy-item")
b.mouse("[data-item='destDir']", "dblclick")
b.click("#dropdown-menu")
b.click("#paste-item")
b.click("[data-item='permissions.txt']")
b.wait_text("#description-list-owner dd", "admin")
b.wait_text("#description-list-group dd", "users")
b.wait_text("#description-list-owner-permissions dd", "Read and write")
b.wait_text("#description-list-group-permissions dd", "None")
b.wait_text("#description-list-other-permissions dd", "None")

@testlib.skipBrowser(".upload_files() doesn't work on Firefox", "firefox")
@testlib.skipImage("Debian-testing has Cockpit 311 without new upload support in fsreplace1", "debian-testing")
def testUpload(self):
Expand Down

0 comments on commit d717557

Please sign in to comment.