 
 (defn downgrade
   [production]
-  (pipeline2/daisy3-to-daisy202))
+  ;; FIXME: Implement properly
+  ;;(pipeline2/daisy3-to-daisy202 (path/encoded-path) downgraded-path)
+)
 
 (defn encode
   [production]

  "Pack a production in an iso file"
  [{:keys [title publisher]
    :or {title "FIXME:" publisher "FIXME:"} ; title and publisher shouldn't be empty
    :as production}]
  (let [encoded-path (.getPath (path/encoded-path production))
        iso-path (path/iso-path production)
        iso-name (.getPath (path/iso-name production))]
    (fs/mkdir iso-path)
    (sh "genisoimage"
        "-quiet"

            (prod/update! (assoc production :state "encoded"))))))
    ;; otherwise move the production to state :pending-volume-split
    (prod/update! (assoc production :state "pending-split"))))

(defn encode-multiple
  [production sample-rate bitrate]
  (dotimes [volume (:volumes production)]
    (let [volume (inc volume) ; we want from 1..n instead of 0..n-1
          result (encode-production production bitrate volume sample-rate)]
      (if (not= 0 (:exit result))
        (log/errorf "Encoding failed with %s" (:err result))
        (do
          ;; downgrade to daisy202
          (downgrade production)
          ;; create an iso
          (create-iso production volume)))))
  ;; set the state to encoded
  (prod/update! (assoc production :state "encoded")))
