Browse Source

Handle error when searching for files

Bob Mottram 9 years ago
parent
commit
2f431f77da
1 changed files with 15 additions and 2 deletions
  1. 15
    2
      src/freedombone-keydrive

+ 15
- 2
src/freedombone-keydrive View File

@@ -141,7 +141,11 @@ if [ ! -d $FRAGMENTS_DIR ]; then
141 141
 fi
142 142
 
143 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 149
 if [[ ${no_of_usb_shares} > 0 ]]; then
146 150
   echo "A key fragment already exists on the drive for the user $MY_USERNAME"
147 151
   umount $USB_MOUNT
@@ -158,10 +162,19 @@ if [ ! -d $LOCAL_FRAGMENTS_DIR ]; then
158 162
 fi
159 163
 
160 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 170
 if [[ ${no_of_local_shares} < 3 ]]; then
163 171
     freedombone-splitkey -u $MY_USERNAME
164 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 178
     no_of_local_shares=$((no_of_shares - 2))
166 179
 fi
167 180