Cypress deletes screenshotsFolder and videosFolder, loosing their original permissions
See original GitHub issueCurrent behavior:
When Cypress is launched using cypress run
with the trashAssetsBeforeRuns=true
, it will delete (move to trash, to be more precise) the whole screenshotsFolder
and videosFolder
. After re-creating them, they’ll have different access control settings (file system-wise) then originally.
See “Steps to reproduce” for details and why it’s an issue.
I realize it’s an exotic issue, and I can work around it fairly easily without fixing Cypress. So feel free to close if you don’t consider this to be a bug.
Desired behavior:
Cypress deletes the contents of screenshotsFolder
and videosFolder
directories, but not the directories themselves. Thus, it preserves their filesystem owner settings, and rwx settings.
Cypress has an option to permanently delete those files, not only move them to trash (to avoid similar issue with the .Trash
directory itself)
Steps to reproduce:
- CI agent is deleting
/artifacts
directory. - CI agent is recreating this directory, as a non-privileged users, so that it looks like:
artifacts/
- screenshots/
- videos/
-
Cypress, running in a Docker container, is executing a test as a root user. It has access to the
/results
folder because it’s mounted as a Docker volume. It deletesscreenshots/
andvideos/
and re-creates them. -
Test passes.
-
Next test is about to run on the very same agent. Agent fails to delete
/results/videos/lorem.mp4
- it has no write access tovideos/
andscreenshots/
, because they were created as root.
Versions
Running in Docker, on Linux. Custom setup, not based on Cypress’ docker images.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:13 (6 by maintainers)
Top GitHub Comments
Hey @kamituel, some more issues popped up with trashing so we opted to permanently delete the contents of directories in Linux as you mentioned. This was done in #2745 and will be released with 3.1.2
Hi everyone, I stumbled upon some very similar scenario and I was wondering: why trash the complete directory? Why not
rm -rf {videosFolder}/*
(idem for screenshots).I know it’s safer/cleaner to
rm
the whole dir but that way also messes with.gitignore
strategies.To be specific: I want to keep the folders (videos & screenshots) so I don’t have to worry about not existing/permissions/etc. So I keep a
.gitignore
inside those dirs, but as the trashing gets rid of the whole dir, my strategy also gets trashed.I think I’m suggesting the same as @brian-mann which, in the end, points to not messing with directory structure of the project
Besides personal or coding strategies, I think trashing the folders will continue to raise problems on different scenarios.