Skip to content

Commit

Permalink
feat(src/os.ml,-src/strings.ml): Introduce tempkeepdays parameter to …
Browse files Browse the repository at this point in the history
…config after how many days should be temporary .unison*.tmp files deleted
  • Loading branch information
LubosKolouch committed Nov 7, 2024
1 parent 96e15a8 commit 25dbe91
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
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

0 comments on commit 25dbe91

Please sign in to comment.