File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed
Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -96,15 +96,23 @@ class SyncToDrive {
9696 throw new Error ( 'Error: USB device is not properly mounted.' ) ;
9797 }
9898
99- log ( 'Starting sync to USB drive ...' ) ;
100- const distinationPath = path . join ( device . mountpoint , this . destination ) ;
101- if ( ! fs . existsSync ( distinationPath ) ) {
102- log ( 'Creating target directory' + distinationPath ) ;
103- fs . mkdirSync ( distinationPath , { recursive : true } ) ;
99+ const destinationPath = path . join ( device . mountpoint , this . destination ) ;
100+ if ( ! fs . existsSync ( destinationPath ) ) {
101+ log ( `Creating target directory ${ destinationPath } ` ) ;
102+ try {
103+ fs . mkdirSync ( destinationPath , { recursive : true } ) ;
104+ } catch ( err ) {
105+ throw new Error ( `Error: Failed to create directory ${ destinationPath } - ${ err . message } ` ) ;
106+ }
104107 }
105108
109+ if ( ! this . isWritable ( destinationPath ) ) {
110+ throw new Error ( `Error: Destination ${ destinationPath } is not writable.` ) ;
111+ }
112+
113+ log ( 'Starting sync to USB drive ...' ) ;
106114 log ( 'Source data folder ' + this . source ) ;
107- log ( 'Syncing to drive ' + device . path + ' -> ' + distinationPath ) ;
115+ log ( 'Syncing to drive ' + device . path + ' -> ' + destinationPath ) ;
108116
109117 const command = [
110118 'rsync' ,
You can’t perform that action at this time.
0 commit comments