Permalink
Browse files

Put temporary snapshot and compact files next to the final file to pr…

…event moves across file systems.
  • Loading branch information...
1 parent a464adb commit d668cb3d2ff6b057525c2684c8455d7117a98b2d @mmcgrana committed Jul 6, 2010
Showing with 2 additions and 7 deletions.
  1. +2 −2 src/clj/fleetdb/embedded.clj
  2. +0 −5 src/clj/fleetdb/file.clj
View
4 src/clj/fleetdb/embedded.clj
@@ -92,7 +92,7 @@
(defn snapshot [dba snapshot-path]
(rassert (ephemeral? dba) "cannot snapshot persistent databases")
- (let [tmp-path (file/tmp-path "/tmp" "snapshot")]
+ (let [tmp-path (str snapshot-path ".tmp")]
(write-db tmp-path @dba)
(file/mv tmp-path snapshot-path)
true))
@@ -109,7 +109,7 @@
(fair-lock/fair-locking (:write-lock (meta dba))
(if (compacting? dba)
false
- (let [tmp-path (file/tmp-path "/tmp" "compact")
+ (let [tmp-path (str (:write-path (meta dba)) ".tmp")
db-at-start @dba]
(alter-meta! dba assoc :write-buf (ArrayList.))
(spawn
View
5 src/clj/fleetdb/file.clj
@@ -7,11 +7,6 @@
(defn size [#^String path]
(.length (File. path)))
-(defn tmp-path [#^String tmp-dir-path prefix]
- (let [tmp-dir (File. tmp-dir-path)
- tmp-file (File/createTempFile prefix nil tmp-dir)]
- (.getAbsolutePath tmp-file)))
-
(defn mv [#^String from #^String to]
(assert (.renameTo (File. from) (File. to))))

0 comments on commit d668cb3

Please sign in to comment.