diff --git a/project.clj b/project.clj index 3954412..3e8941f 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject updog "0.2.0" +(defproject updog "0.2.1-SNAPSHOT" :description "Your watchdog for updates of software without updates." :url "https://github.com/walterl/updog" :license {:name "GPLv3" diff --git a/src/updog/cli.clj b/src/updog/cli.clj index 67ef043..4780cd9 100644 --- a/src/updog/cli.clj +++ b/src/updog/cli.clj @@ -13,6 +13,7 @@ [["-d" "--db APPSDB" "EDN apps database to use." :default "appsdb.edn" :validate [fs/exists? "Apps database file not found."]] + ["-L" "--long-log" "Use longer log output format."] ["-v" "--verbose" "Enable verbose output (set log level to debug)."] ["-h" "--help" "Display help text and exit."]] ) @@ -256,6 +257,7 @@ {:output (usage cmd)} :else - (run-command! {:db-file (:db options) - :log-level (if (:verbose options) :debug :info)} + (run-command! {:db-file (:db options) + :log-level (if (:verbose options) :debug :info) + :log-format (when (:long-log options) :long)} cmd cmd-opts)))) diff --git a/src/updog/system.clj b/src/updog/system.clj index df23eea..186a4e3 100644 --- a/src/updog/system.clj +++ b/src/updog/system.clj @@ -4,10 +4,12 @@ (defn init "Initialize the application integrant system, using app `db-file`." - [{:keys [db-file log-level]}] + [{:keys [db-file log-level log-format]}] (let [config (cond-> (-> (io/resource "system_config.edn") slurp ig/read-string) - db-file (assoc-in [:updog.apps-db.edn-db/apps-db :filename] db-file) - log-level (assoc-in [:updog.logging/timbre-logger :log-level] log-level))] + db-file (assoc-in [:updog.apps-db.edn-db/apps-db :filename] db-file) + log-level (assoc-in [:updog.logging/timbre-logger :log-level] log-level) + log-format (assoc-in [:updog.logging/timbre-logger :use-default-output-fn?] + (= log-format :long)))] (ig/load-namespaces config) (-> config ig/prep diff --git a/src/updog/updater.clj b/src/updog/updater.clj index b9d8f19..276810b 100644 --- a/src/updog/updater.clj +++ b/src/updog/updater.clj @@ -8,12 +8,6 @@ [updog.unpack :as unpack] [updog.util :as u])) -(defn- newer-version? - "Is version `a` newer than `b`? Always returns `true` if `b` is nil." - [a b] - (or (nil? b) - (pos? (compare a b)))) - (defn- has-latest-version? [{:keys [latest-version]}] (and latest-version (:version latest-version))) @@ -33,12 +27,22 @@ (cond (not (fs/exists? dest-path)) (do - (log/debugf "File not found: %s" dest-path) + (log/debugf "App %s file not found: %s" app-name dest-path) + true) + + ;; Don't know what version we have; download the latest to be safe + (not last-version) + (do + (log/debugf "No last version for app %s. Updating to %s" app-name latest-version) true) - (newer-version? latest-version last-version) + ;; If the latest published version is different than the one we have, we + ;; should probably change to it, regardless of whether it's semantically + ;; newer or not. This is to account for accidental or retracted releases. + ;; I.e. trust what upstream says is the latest, and use that. + (not= last-version latest-version) (do - (log/debugf "App %s %s has newer version: %s" + (log/debugf "App %s %s will be updated to version: %s" app-name last-version latest-version) true) @@ -104,10 +108,10 @@ (selected-apps app-key))] (try (update-file (assoc app - :app-key app-key - :tmp-dir base-tmp-dir - :db db - :source (source-of-type sources (:source-type app)))) + :app-key app-key + :tmp-dir base-tmp-dir + :db db + :source (source-of-type sources (:source-type app)))) (catch Throwable ex (log/errorf ex "Failed to update app %s" app-key)))))))