Browse Source

Better checks for disk availability

Zachary Kotlarek 13 năm trước cách đây
mục cha
commit
28de913d88
1 tập tin đã thay đổi với 15 bổ sung và 2 xóa
  1. 15 2
      sync.sh

+ 15 - 2
sync.sh

@@ -34,11 +34,24 @@ if [ ! -d "${BASE_LOCAL}/${SUB_DIR}" ]; then
 	exit 1
 	exit 1
 fi
 fi
 if [ ! -d "${BASE_REMOTE}" ]; then
 if [ ! -d "${BASE_REMOTE}" ]; then
-	echo "Bitcasa drive not mounted" 1>&2
+	echo "Remote drive not mounted" 1>&2
 	exit 1
 	exit 1
 fi
 fi
 
 
-# Ensure the subdirectory exists on the remote drive
+# Ensure we can actually write to the remote drive
+WC="${BASE_REMOTE}/.write_check"
+touch "${WC}" >/dev/null 2>&1
+if [ ! -e "${WC}" ]; then
+	echo "Remote drive not writable" 1>&2
+	exit 1
+fi
+rm -f "${WC}" >/dev/null 2>&1
+if [ -e "${WC}" ]; then
+	echo "Remote drive not writable" 1>&2
+	exit 1
+fi
+
+# Create the named subdirectory if it does not exist on the remote drive
 if [ ! -d "${BASE_REMOTE}/${SUB_DIR}" ]; then
 if [ ! -d "${BASE_REMOTE}/${SUB_DIR}" ]; then
 	mkdir -p "${BASE_REMOTE}/${SUB_DIR}"
 	mkdir -p "${BASE_REMOTE}/${SUB_DIR}"
 fi
 fi