Commit Graph

16 Commits

Author SHA1 Message Date
Alexander Larsson f198ee525a Properly close archives
All archive that are created from somewhere generally have to be closed, because
at some point there is a file or a pipe or something that backs them. So, we
make archive.Archive a ReadCloser. However, code consuming archives does not
typically close them so we add an archive.ArchiveReader and use that when we're
only reading.

We then change all the Tar/Archive places to create ReadClosers, and to properly
close them everywhere.

As an added bonus we can use ReadCloserWrapper rather than EofReader in several places,
which is good as EofReader doesn't always work right. For instance, many compression
schemes like gzip knows it is EOF before having read the EOF from the stream, so the
EofCloser never sees an EOF.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-02-14 13:46:17 +01:00
Alexander Larsson 710d5a48fb archive: Extract createTarFile() from ApplyLayer
This way we can reuse it for Untar()

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-01-14 11:21:07 +01:00
Ben Wiklund 0fccf0f686 small batch of edits/corrections to comments 2013-12-24 16:40:14 -08:00
Alexander Larsson a96a26c62f Handle compressed tars in ApplyLayer
When pulling from a registry we get a compressed tar archive, so
we need to wrap the stream in the right kind of compress reader.

Unfortunately go doesn't have an Xz decompression method, but I
don't think any docker layers use that atm anyway.
2013-12-17 14:19:48 +01:00
Alexander Larsson 78c22c24b3 ApplyLayer: Fix TestLookupImage
The TestLookupImage test seems to use a layer that contains
/etc/postgres/postgres.conf, but not e.g. /etc/postgres.

To handle this we ensure that the parent directory always
exists, and if not we create it.
2013-12-16 14:35:43 +01:00
Alexander Larsson 818c249bae archive: Implement ApplyLayer directly
Rather than calling out to tar we use the golang tar parser
to directly extract the tar files. This has two major advantages:

1) We're able to replace an existing directory with a file in the
   new layer. This currently breaks with the external tar, since
   it refuses to recursively remove the destination directory in
   this case, and there are no options to make it do that.

2) We avoid extracting the whiteout files just to later remove them.
2013-12-13 15:43:50 +01:00
Andrews Medina 8b2a7e35c3 Move syscall.Stats logic to os specific file.
related to #2909.
2013-11-28 00:22:47 -02:00
Michael Crosby 3edb4af663 Ensure same atime, mtime after applying whiteouts 2013-11-19 00:35:03 -08:00
Alexander Larsson 006e2a600c ApplyLayer() use RemoveAll to handle removing directories
rmTargetPath can be a directory, so we have to use RemoveAll() or we
will fail to whiteout non-empty directories.
2013-11-14 22:56:18 +01:00
Guillaume J. Charmes 50d80a8938 Merge pull request #17 from alexlarsson/dm-plugin-whiteout-directory
archive.ApplyLayer() - handle directory whiteouts
2013-11-12 12:16:30 -08:00
Alexander Larsson 6f3c32eb18 archive.ApplyLayer() - handle directory whiteouts
When directories are white-outed we can get called with the previously
removed directories. Handle this with os.IsNotExist(error).
2013-11-12 21:14:54 +01:00
Michael Crosby 5d9723002b Allow drivers to implement ApplyDiff in Differ interface 2013-11-11 19:09:57 -08:00
Solomon Hykes 78ef0bd998 Merge pull request #6 from alexlarsson/fix-ApplyLayer-remove
archive.ApplyLayer() remove files recursively
2013-11-08 11:46:55 -08:00
Solomon Hykes f1127b9308 gofmt 2013-11-07 23:58:03 +00:00
Alexander Larsson 484804abff archive.ApplyLayer() remove files recursively
Some aufs metadata are directories, and whiteouts can be for
directories, so use os.RemoveAll() for these.
2013-11-07 22:46:44 +01:00
Solomon Hykes 318dd33fb7 archive.ApplyLayer(): parse a tar archive as a standard aufs-compatible diff, and apply it on a directory 2013-11-01 05:06:35 +00:00