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

feat(src/os.ml,-src/strings.ml): Introduce tempkeepdays parameter to config after how many days should be temporary .unison*.tmp files deleted #1081

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/os.ml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,13 @@ let allChildrenOf fspath path =
| None ->
[])


let tempkeepdays: int Prefs.t =
Prefs.createInt "tempkeepdays" 30
~category:(`Advanced `General)
"set the number of days to keep temporary files"
"Specifies the number of days temporary files are kept before being deleted."

(* Assumes that (fspath, path) is a directory, and returns the list of *)
(* children, except for temporary files and AppleDouble files. *)
let rec childrenOf fspath path =
Expand All @@ -138,8 +145,8 @@ let rec childrenOf fspath path =
if Util.endswith file !tempFileSuffix then begin
let p = Path.child path filename in
let i = Fileinfo.getBasic false fspath p in
let secondsinthirtydays = 2592000.0 in
if Props.time i.Fileinfo.desc +. secondsinthirtydays < Util.time()
let secondsInRetentionPeriod = float_of_int (Prefs.read tempkeepdays) *. 86400.0 in
if Props.time i.Fileinfo.desc +. secondsInRetentionPeriod < Util.time()
then begin
debug (fun()-> Util.msg "deleting old temp file %s\n"
(Fspath.toDebugString (Fspath.concat fspath p)));
Expand Down
1 change: 1 addition & 0 deletions src/strings.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,7 @@ let docs =
\032 -rootalias xxx register alias for canonical root names\n\
\032 -showarchive show 'true names' (for rootalias) of roots and archive\n\
\032 -source xxx include a file's preferences\n\
\032 -tempkeepdays n after how many days should be temporary files deleted
\032 -ui xxx select UI ('text' or 'graphic'); command-line only\n\
\032 -unicode xxx assume Unicode encoding in case insensitive mode\n\
\032 -watch when set, use a file watcher process to detect changes\n\
Expand Down