浏览代码

Empty the trash manually, if conditions are safe

Zachary Kotlarek 13 年之前
父节点
当前提交
2122d9c1af
共有 2 个文件被更改,包括 22 次插入 和 0 次删除
  1. 19 0
      pms/emptyTrash.sh
  2. 3 0
      pms/scan.sh

+ 19 - 0
pms/emptyTrash.sh

@@ -0,0 +1,19 @@
+#!/bin/bash
+
+# Bail if the media share isn't mounted
+if ! ~/bin/video/isMediaMounted; then
+	exit 0
+fi
+
+# Bail if we are already scanning
+if ~/bin/video/pms/isScanning.sh; then
+	exit 0
+fi
+
+# Read the list of section numbers
+SECTIONS="`curl 'http://localhost:32400/library/sections' | grep '<Directory ' | sed 's%^.* key="\([0-9]*\)".*$%\1%'`"
+
+# Empty the trash for each section
+for i in $SECTIONS; do
+	curl --silent --upload-file /dev/null "http://localhost:32400/library/sections/${i}/emptyTrash"
+done

+ 3 - 0
pms/scan.sh

@@ -22,3 +22,6 @@ fi
 if echo "${@}" | grep -q -- '--deep'; then
 if echo "${@}" | grep -q -- '--deep'; then
 	~/bin/video/pms/optimize.sh
 	~/bin/video/pms/optimize.sh
 fi
 fi
+
+# Clean the trash, if conditions are safe
+~/bin/video/pms/emptyTrash.sh