[pkg-d-commits] [ldc] 29/149: cache: Delete all temporary files during cache pruning.

Matthias Klumpp mak at moszumanska.debian.org
Sun Apr 23 22:36:54 UTC 2017


This is an automated email from the git hooks/post-receive script.

mak pushed a commit to annotated tag v1.2.0
in repository ldc.

commit 356a241659af3e862aeae4e126b7d78d8583067a
Author: Johan Engelen <jbc.engelen at gmail.com>
Date:   Sat Jan 7 16:34:58 2017 +0100

    cache: Delete all temporary files during cache pruning.
---
 driver/cache_pruning.d | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/driver/cache_pruning.d b/driver/cache_pruning.d
index 38247b6..93ce1b5 100644
--- a/driver/cache_pruning.d
+++ b/driver/cache_pruning.d
@@ -109,6 +109,9 @@ struct CachePruner
         auto filePattern = "ircache_????????????????????????????????.{o,obj}";
         auto cacheFiles = dirEntries(cachePath, filePattern, SpanMode.shallow, /+ followSymlink +/ false);
 
+        // Delete all temporary files.
+        deleteFiles(cachePath, filePattern ~ ".tmp???????");
+
         // Files that have not yet expired, may still be removed during pruning for size later.
         // This array holds the prune candidates after pruning for expiry.
         DirEntry[] pruneForSizeCandidates;
@@ -121,6 +124,22 @@ struct CachePruner
     }
 
 private:
+    void deleteFiles(string path, string filePattern)
+    {
+        foreach (DirEntry f; dirEntries(path, filePattern, SpanMode.shallow, /+ followSymlink +/ false))
+        {
+            try
+            {
+                remove(f.name);
+            }
+            catch (FileException)
+            {
+                // Simply skip the file when an error occurs.
+                continue;
+            }
+        }
+    }
+
     void pruneForExpiry(T)(T cacheFiles, out DirEntry[] remainingPruneCandidates, out ulong cacheSize)
     {
         foreach (DirEntry f; cacheFiles)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git



More information about the pkg-d-commits mailing list