saving retries if it fails.
This commit is contained in:
@@ -100,7 +100,16 @@
|
||||
(edn/read-string (.getString prefs "chapters"))
|
||||
saves/chapters)))
|
||||
|
||||
(defn try-times [fn times]
|
||||
(first (drop-while #{:fail}
|
||||
(repeatedly times
|
||||
#(try (fn)
|
||||
(catch Exception e
|
||||
(log/error "Could not save!" e)
|
||||
:fail))))))
|
||||
|
||||
(defn save [entities id name & [blurb]]
|
||||
(let [save-fn (fn []
|
||||
(log/info "Saving " id name)
|
||||
(let [save {:name name
|
||||
:id id
|
||||
@@ -117,7 +126,8 @@
|
||||
pm (ScreenUtils/getFrameBufferPixmap x y w h)
|
||||
resized (Pixmap. 160 120 Pixmap$Format/RGB888)
|
||||
_ (.drawPixmap resized pm 0 0 w h 0 0 160 120)]
|
||||
(steam/save-screenshot resized (steam/save-screenshot-file-name id))))))
|
||||
(steam/save-screenshot resized (steam/save-screenshot-file-name id))))))]
|
||||
(try-times save-fn 3)))
|
||||
|
||||
(defn remove-save [id]
|
||||
(doseq [f [(steam/save-screenshot-file-name id)
|
||||
|
||||
Reference in New Issue
Block a user