@@ -57,8 +57,14 @@ impl<'a, 'b, 'c> ContainerDataVolume<'a, 'b, 'c> {
57
57
. run_and_get_status ( msg_info, false )
58
58
}
59
59
60
- // copy files for a docker volume, for remote host support
61
- // NOTE: `reldst` has the same caveats as `reldir` in `create_dir`.
60
+ /// Copy files for a docker volume
61
+ ///
62
+ /// `reldst` has the same caveats as `reldir` in [`Self::create_dir`].
63
+ ///
64
+ /// ## Note
65
+ ///
66
+ /// if copying from a src directory to dst directory with docker, to
67
+ /// copy the contents from `src` into `dst`, `src` must end with `/.`
62
68
#[ track_caller]
63
69
fn copy_files (
64
70
& self ,
@@ -67,14 +73,33 @@ impl<'a, 'b, 'c> ContainerDataVolume<'a, 'b, 'c> {
67
73
mount_prefix : & str ,
68
74
msg_info : & mut MessageInfo ,
69
75
) -> Result < ExitStatus > {
76
+ if let Some ( ( _, rel) ) = reldst. rsplit_once ( '/' ) {
77
+ if msg_info. cross_debug
78
+ && src. is_dir ( )
79
+ && !src. to_string_lossy ( ) . ends_with ( "/." )
80
+ && rel == src. file_name ( ) . unwrap ( )
81
+ {
82
+ msg_info. warn ( format_args ! (
83
+ "source is pointing to a directory instead of its contents: {} -> {}\n This might be a bug. {}" ,
84
+ src. as_posix_relative( ) ?,
85
+ reldst,
86
+ std:: panic:: Location :: caller( )
87
+ ) ) ?;
88
+ }
89
+ }
70
90
subcommand_or_exit ( self . engine , "cp" ) ?
71
91
. arg ( "-a" )
72
92
. arg ( src. to_utf8 ( ) ?)
73
93
. arg ( format ! ( "{}:{mount_prefix}/{reldst}" , self . container) )
74
94
. run_and_get_status ( msg_info, false )
75
95
}
76
96
77
- // copy files for a docker volume, for remote host support
97
+ /// copy files for a docker volume, does not include cache directories
98
+ ///
99
+ /// ## Note
100
+ ///
101
+ /// if copying from a src directory to dst directory with docker, to
102
+ /// copy the contents from `src` into `dst`, `src` must end with `/.`
78
103
#[ track_caller]
79
104
fn copy_files_nocache (
80
105
& self ,
@@ -114,8 +139,7 @@ impl<'a, 'b, 'c> ContainerDataVolume<'a, 'b, 'c> {
114
139
file:: create_dir_all ( dst_path. parent ( ) . expect ( "must have parent" ) ) ?;
115
140
fs:: copy ( src_path, & dst_path) ?;
116
141
}
117
- // if copying from a src directory to dst directory with docker, to
118
- // copy the contents from `src` into `dst`, `src` must end with `/.`
142
+
119
143
self . copy_files ( & temppath. join ( "." ) , reldst, mount_prefix, msg_info)
120
144
}
121
145
@@ -196,7 +220,7 @@ impl<'a, 'b, 'c> ContainerDataVolume<'a, 'b, 'c> {
196
220
mount_prefix,
197
221
msg_info,
198
222
) ?;
199
- self . copy_files ( dirs. xargo ( ) , & reldst, mount_prefix, msg_info) ?;
223
+ self . copy_files ( & dirs. xargo ( ) . join ( "." ) , & reldst, mount_prefix, msg_info) ?;
200
224
}
201
225
202
226
Ok ( ( ) )
@@ -215,11 +239,11 @@ impl<'a, 'b, 'c> ContainerDataVolume<'a, 'b, 'c> {
215
239
. map ( |s| bool_from_envvar ( & s) )
216
240
. unwrap_or ( copy_registry) ;
217
241
242
+ self . create_dir ( & reldst, mount_prefix, msg_info) ?;
218
243
if copy_registry {
219
- self . copy_files ( dirs. cargo ( ) , & reldst, mount_prefix, msg_info) ?;
244
+ self . copy_files ( & dirs. cargo ( ) . join ( "." ) , & reldst, mount_prefix, msg_info) ?;
220
245
} else {
221
246
// can copy a limit subset of files: the rest is present.
222
- self . create_dir ( & reldst, mount_prefix, msg_info) ?;
223
247
for entry in fs:: read_dir ( dirs. cargo ( ) )
224
248
. wrap_err_with ( || format ! ( "when reading directory {:?}" , dirs. cargo( ) ) ) ?
225
249
{
@@ -380,9 +404,9 @@ impl<'a, 'b, 'c> ContainerDataVolume<'a, 'b, 'c> {
380
404
) -> Result < ( ) > {
381
405
let copy_all = |info : & mut MessageInfo | {
382
406
if copy_cache {
383
- self . copy_files ( src, reldst, mount_prefix, info)
407
+ self . copy_files ( & src. join ( "." ) , reldst, mount_prefix, info)
384
408
} else {
385
- self . copy_files_nocache ( src, reldst, mount_prefix, true , info)
409
+ self . copy_files_nocache ( & src. join ( "." ) , reldst, mount_prefix, true , info)
386
410
}
387
411
} ;
388
412
match volume {
0 commit comments