   [production]
   (archive-master production)
   (archive-distribution-master production))
-  

   :flags "x"
   :transaktions_status "pending"})

(defn container-id 
  "Return the name of a archive spool directory for a given production"
  [{:keys [id iso-path]}]
  (cond

  [{:keys [path] :as production}]
  (let [tmp-path (.getPath (fs/temp-dir "mdr2"))
        ;; FIXME: it might be better to allow for different manifest names
        manifest (.getPath (file path "package.opf"))]
    (pipeline/audio-encoder {:input manifest :output tmp-path})
    (assoc production :encoded-path tmp-path)))

(defn create-iso
  "Pack a production in an iso file.
Return a map with an additional key `iso-path` where the iso is located"
  [{:keys [encoded-path title publisher]
    :or {title "FIXME:" publisher "FIXME:"} ; title and publisher shouldn't be empty
    :as production}]
  (let [iso-path (.getPath (file (fs/tmpdir) (fs/temp-name "mdr2" ".iso")))]
    (sh "genisoimage"
        "-quiet"
        "-r"
        "-publisher" publisher
        "-V" title ; volume ID (volume name or label)
        "-J" ; Generate Joliet directory records in addition to regular ISO9660 filenames.
        "-o" iso-path encoded-path)
    (assoc production :iso-path iso-path)))

(defn copy-files
  "Copy a production to the archive spool dir"
  ;; FIXME: this fails if there is already an archiving in progress
  ;; because it will create another copy inside the already existing
