Add fs.remove_dir_recursive() for temp directory cleanup #36

Closed
opened 2026-07-19 05:53:00 +02:00 by michael · 3 comments
Owner

daw.common.fs currently has no equivalent to 'rm -rf' for recursive directory removal. fs.remove() only handles single files / empty directories via os.remove().

Use case: daw-module-manager/sig.lua creates a temp dir via fs.tmpdir() (mktemp -d) to hold a pubkey during signature verification, and needs to clean it up afterwards -- currently falls back to sys:run_rc('rm -rf ' .. dir) directly in program code, which daw-code-standard.md flags as a violation (external calls belong in common/adapters).

Needs: fs.remove_dir_recursive(path) -> true, nil | nil, err. Should probably build on fs.list_files/fs.list_dirs recursion + fs.remove, or shell out via daw.common.sys internally (fs is allowed to use sys, program code is not).

Related: DAW/daw-module-manager (sig.lua TMPDIR cleanup).

daw.common.fs currently has no equivalent to 'rm -rf' for recursive directory removal. fs.remove() only handles single files / empty directories via os.remove(). Use case: daw-module-manager/sig.lua creates a temp dir via fs.tmpdir() (mktemp -d) to hold a pubkey during signature verification, and needs to clean it up afterwards -- currently falls back to sys:run_rc('rm -rf ' .. dir) directly in program code, which daw-code-standard.md flags as a violation (external calls belong in common/adapters). Needs: fs.remove_dir_recursive(path) -> true, nil | nil, err. Should probably build on fs.list_files/fs.list_dirs recursion + fs.remove, or shell out via daw.common.sys internally (fs is allowed to use sys, program code is not). Related: DAW/daw-module-manager (sig.lua TMPDIR cleanup).
Author
Owner

Implemented in fs/dir.lua, shells out via daw.common.sys (rm -rf). Wired into fs/init.lua and dev-module-map.lua. Tested in test_fs.lua including the guardrails against path == "/" or "".

Implemented in fs/dir.lua, shells out via daw.common.sys (rm -rf). Wired into fs/init.lua and dev-module-map.lua. Tested in test_fs.lua including the guardrails against path == "/" or "".
Author
Owner

Implemented in fs/dir.lua, shells out via daw.common.sys (rm -rf). Wired into fs/init.lua and dev-module-map.lua. Tested in test_fs.lua including the guardrails against path == "/" or "".

Implemented in fs/dir.lua, shells out via daw.common.sys (rm -rf). Wired into fs/init.lua and dev-module-map.lua. Tested in test_fs.lua including the guardrails against path == "/" or "".
Author
Owner

Implemented in fs/dir.lua, shells out via daw.common.sys (rm -rf). Wired into fs/init.lua and dev-module-map.lua. Tested in test_fs.lua including the guardrails against path == "/" or "".

Implemented in fs/dir.lua, shells out via daw.common.sys (rm -rf). Wired into fs/init.lua and dev-module-map.lua. Tested in test_fs.lua including the guardrails against path == "/" or "".
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DAW/daw-lua-common#36
No description provided.