@@ -92,7 +92,9 @@ impl<'a, 'b, 'c> ContainerDataVolume<'a, 'b, 'c> {
92
92
file:: create_dir_all ( dst_path. parent ( ) . expect ( "must have parent" ) ) ?;
93
93
fs:: copy ( & src_path, & dst_path) ?;
94
94
}
95
- self . copy_files ( temppath, dst, msg_info)
95
+ // if copying from a src directory to dst directory with docker, to
96
+ // copy the contents from `src` into `dst`, `src` must end with `/.`
97
+ self . copy_files ( & temppath. join ( "." ) , dst, msg_info)
96
98
}
97
99
98
100
// removed files from a docker volume, for remote host support
@@ -351,15 +353,17 @@ impl<'a, 'b, 'c> ContainerDataVolume<'a, 'b, 'c> {
351
353
// have stale data: the persistent volume was deleted & recreated.
352
354
if fingerprint. exists ( ) && self . container_path_exists ( dst, msg_info) ? {
353
355
let previous = Fingerprint :: read_file ( & fingerprint) ?;
354
- let ( changed, removed) = previous. difference ( & current) ;
355
- current. write_file ( & fingerprint) ?;
356
-
357
- if !changed. is_empty ( ) {
358
- self . copy_file_list ( src, dst, & changed, msg_info) ?;
356
+ let ( to_copy, to_remove) = previous. difference ( & current) ;
357
+ if !to_copy. is_empty ( ) {
358
+ self . copy_file_list ( src, dst, & to_copy, msg_info) ?;
359
359
}
360
- if !removed . is_empty ( ) {
361
- self . remove_file_list ( dst, & removed , msg_info) ?;
360
+ if !to_remove . is_empty ( ) {
361
+ self . remove_file_list ( dst, & to_remove , msg_info) ?;
362
362
}
363
+
364
+ // write fingerprint afterwards, in case any failure so we
365
+ // ensure any changes will be made on subsequent runs
366
+ current. write_file ( & fingerprint) ?;
363
367
} else {
364
368
current. write_file ( & fingerprint) ?;
365
369
copy_all ( msg_info) ?;
@@ -530,22 +534,21 @@ impl Fingerprint {
530
534
Ok ( result)
531
535
}
532
536
533
- // gets difference between previous and current
537
+ // returns to_copy (added + modified) and to_remove (removed).
534
538
fn difference < ' a , ' b > ( & ' a self , current : & ' b Fingerprint ) -> ( Vec < & ' b str > , Vec < & ' a str > ) {
535
- // this can be added or updated
536
- let changed: Vec < & str > = current
539
+ let to_copy: Vec < & str > = current
537
540
. map
538
541
. iter ( )
539
542
. filter ( |( k, v1) | self . map . get ( * k) . map_or ( true , |v2| v1 != & v2) )
540
543
. map ( |( k, _) | k. as_str ( ) )
541
544
. collect ( ) ;
542
- let removed : Vec < & str > = self
545
+ let to_remove : Vec < & str > = self
543
546
. map
544
547
. iter ( )
545
548
. filter ( |( k, _) | !current. map . contains_key ( * k) )
546
549
. map ( |( k, _) | k. as_str ( ) )
547
550
. collect ( ) ;
548
- ( changed , removed )
551
+ ( to_copy , to_remove )
549
552
}
550
553
}
551
554
0 commit comments