 (defn add-pending-file
   "Adds a new or changing file to the list of pending files."
   [file]
-  (log/trace "adding pending file" (str file))
-  (dosync (alter pending-files conj file)))
+  (when-not (contains? @pending-files file)
+    (log/trace "adding pending file" (str file))
+    (dosync (alter pending-files conj file))))
 
 (defn remove-file
   "Removes the file from the video library."

  "Checks the pending files and adds the stable ones to the library."
  [folder]
  (when (seq @pending-files)
    (log/trace "checking pending files")
    (doseq [file @pending-files]
      (try (when (stable? file)
             (dosync (alter pending-files disj file))

(defn file-event-callback
  "Processes the file system events."
  [folder event filename]
  (when (or (file/video? filename) (file/subtitles? filename))
    (let [file (io/file filename)]
      (try (case event
             :create (do
                       (log/info "watching file" filename)
                       (add-pending-file file))
             :modify (add-pending-file file)
             :delete (remove-file folder file)
             nil)
