if !strings.HasPrefix(mnt, src+"/") {
continue
}
- if mntinfo.Kind == "text" || mntinfo.Kind == "json" {
+ if cp.copyRegularFiles(mntinfo) {
// These got copied into the nearest parent
// mount as regular files during setup, so
// they get copied as regular files when we
if _, isSecret := cp.secretMounts[src]; isSecret {
continue
}
- if mntinfo, isMount := cp.mounts[src]; isMount && mntinfo.Kind != "text" && mntinfo.Kind != "json" {
+ if mntinfo, isMount := cp.mounts[src]; isMount && !cp.copyRegularFiles(mntinfo) {
// If a regular file/dir somehow
// exists at a path that's also a
// mount target, ignore the file --
// the mount has already been included
// with walkMountsBelow().
//
- // (...except json/text mounts, which
- // are handled as regular files.)
+ // (...except mount types that are
+ // handled as regular files.)
continue
}
err = cp.walkHostFS(dest, src, maxSymlinks, false)
return fmt.Errorf("Unsupported file type (mode %o) in output dir: %q", fi.Mode(), src)
}
+func (cp *copier) copyRegularFiles(m arvados.Mount) bool {
+ return m.Kind == "text" || m.Kind == "json" || (m.Kind == "collection" && m.Writable)
+}
+
func (cp *copier) getManifest(pdh string) (*manifest.Manifest, error) {
if mft, ok := cp.manifestCache[pdh]; ok {
return mft, nil
c.Check(err, check.NotNil)
}
-func (s *copierSuite) TestUnsupportedWritableMountBelow(c *check.C) {
- s.cp.mounts["/ctr/outdir/dirk"] = arvados.Mount{
+func (s *copierSuite) TestWritableMountBelow(c *check.C) {
+ s.cp.mounts["/ctr/outdir/mount"] = arvados.Mount{
Kind: "collection",
PortableDataHash: arvadostest.FooPdh,
Writable: true,
}
+ c.Assert(os.MkdirAll(s.cp.hostOutputDir+"/mount", 0755), check.IsNil)
+ s.writeFileInOutputDir(c, "file", "file")
+ s.writeFileInOutputDir(c, "mount/foo", "foo")
+
err := s.cp.walkMount("", s.cp.ctrOutputDir, 10, true)
- c.Check(err, check.NotNil)
+ c.Check(err, check.IsNil)
+ c.Check(s.cp.dirs, check.DeepEquals, []string{"/mount"})
+ c.Check(s.cp.files, check.DeepEquals, []filetodo{
+ {src: s.cp.hostOutputDir + "/file", dst: "/file", size: 4},
+ {src: s.cp.hostOutputDir + "/mount/foo", dst: "/mount/foo", size: 3},
+ })
}
func (s *copierSuite) writeFileInOutputDir(c *check.C, path, data string) {