瀏覽代碼

Handle error when searching for files

Bob Mottram 10 年之前
父節點
當前提交
2f431f77da
共有 1 個檔案被更改,包括 15 行新增2 行删除
  1. 15
    2
      src/freedombone-keydrive

+ 15
- 2
src/freedombone-keydrive 查看文件

141
 fi
141
 fi
142
 
142
 
143
 no_of_usb_shares=$(ls -afq $FRAGMENTS_DIR/keyshare.asc.* | wc -l)
143
 no_of_usb_shares=$(ls -afq $FRAGMENTS_DIR/keyshare.asc.* | wc -l)
144
-no_of_usb_shares=$((no_of_usb_shares - 2))
144
+if [ ! "$?" = "0" ]; then
145
+    no_of_usb_shares=0
146
+else
147
+    no_of_usb_shares=$((no_of_usb_shares - 2))
148
+fi
145
 if [[ ${no_of_usb_shares} > 0 ]]; then
149
 if [[ ${no_of_usb_shares} > 0 ]]; then
146
   echo "A key fragment already exists on the drive for the user $MY_USERNAME"
150
   echo "A key fragment already exists on the drive for the user $MY_USERNAME"
147
   umount $USB_MOUNT
151
   umount $USB_MOUNT
158
 fi
162
 fi
159
 
163
 
160
 no_of_local_shares=$(ls -afq $LOCAL_FRAGMENTS_DIR/keyshare.asc.* | wc -l)
164
 no_of_local_shares=$(ls -afq $LOCAL_FRAGMENTS_DIR/keyshare.asc.* | wc -l)
161
-no_of_local_shares=$((no_of_shares - 2))
165
+if [ ! "$?" = "0" ]; then
166
+    no_of_local_shares=0
167
+else
168
+    no_of_local_shares=$((no_of_local_shares - 2))
169
+fi
162
 if [[ ${no_of_local_shares} < 3 ]]; then
170
 if [[ ${no_of_local_shares} < 3 ]]; then
163
     freedombone-splitkey -u $MY_USERNAME
171
     freedombone-splitkey -u $MY_USERNAME
164
     no_of_local_shares=$(ls -afq $LOCAL_FRAGMENTS_DIR/keyshare.asc.* | wc -l)
172
     no_of_local_shares=$(ls -afq $LOCAL_FRAGMENTS_DIR/keyshare.asc.* | wc -l)
173
+    if [ ! "$?" = "0" ]; then
174
+        no_of_local_shares=0
175
+    else
176
+        no_of_local_shares=$((no_of_local_shares - 2))
177
+    fi
165
     no_of_local_shares=$((no_of_shares - 2))
178
     no_of_local_shares=$((no_of_shares - 2))
166
 fi
179
 fi
167
 
180