Commit graph

16 commits

Author SHA1 Message Date
c0a5cb25ec
-d: exclude non-directories
Adding flag, and supporting functionality for exluding entries that are
non-directories

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-11-17 22:43:02 -05:00
4eec68be4b
*: make Keyword and KeyVal pervasive
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-11-17 21:38:01 -05:00
Aleksa Sarai
704d91fc7c
keywords: safely encode symlink keywords
symlink(2) is a very dumb syscall, and allows you to put any damn value
you please inside a symlink. In addition, spaces are valid path
characters which causes issues with keyword parsing. So use Vis() and
Unvis() to safely store an encoded version of the path.

This also adds a cli test for this behaviour.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2016-11-12 01:52:37 +11:00
Stephen Chung
3973da9b81 tar: remove completed TODO's and dead code
minor clean-up of some comments and code that is not used
in tar functionality

Signed-off-by: Stephen Chung <spchung@andrew.cmu.edu>
2016-08-21 15:41:28 -04:00
Stephen Chung
5837d00b07 tar: resolve hardlinks when streaming archive
Fill in the data of the Entry with the data of the
file that a hardlink actually represents.

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-08-11 13:24:44 -04:00
2a99b062a7 tar: more clear if predicate
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-08-10 13:46:14 -04:00
Stephen Chung
00a4a2e674 tar: remove "time" keyword before tree creation
Instead of checking each time during keyword evaluation if
the keyword is "time", just remove it from the start and
replace it with "tar_time" (if necessary).

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-08-10 13:17:16 -04:00
Stephen Chung
3d6b74d6f7 tar: populate Entry tree under a common root
Resolves #56. Now, the Entry tree will be populated
under a common root (if necessary), so that a manifest can
be accurately generate from a tar file that has been
created using multiple directories.

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-08-09 12:09:36 -04:00
Stephen Chung
6a37331074 tar: flatten the pseudo-tree only after readHeaders() is done
Flattening within the readHeaders() function call was problematic
because readHeaders() is called as a goroutine; thus, as the
main program was calling `tdh.writeTo(os.Stdout)`, readHeaders() was
still in the process of flattening the tree structure. To get around this,
we now call flatten in ts.Hierarchy(), such that only when the main program
is ready to retrieve a "valid" DirectoryHierarchy from the archive, should
we flatten the tree.

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-08-02 11:42:02 -04:00
Stephen Chung
822f319224 tar: minor refactoring of populateTree and flatten
Cleaned up some dead code, and made populateTree not
take in a *tar.Streamer argument, as the ts argument was
only used to set an error. The function now returns
an error (if any). Also made flatten not have to take in
a *tar.Streamer argument as well.

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-07-31 22:26:55 -04:00
Stephen Chung
767d4bbb4b tar: explicitly close files after populateTree
Files don't close properly when `defer`ing inside
a for loop, since the surrounding function is still
iterating in a for loop. To fix this, just close the files
explicitly after `populateTree()` in `readHeaders()`

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-07-25 20:04:55 -04:00
Stephen Chung
773763fb87 vis: refactored code to reflect using vis/unvis for file names
Added some more test cases for `vis`ing and `unvis`ing
strings, and a test case that walks/checks a directory with
filenames that require encoding. Had to change Path() to account
for possible errors Unvis() could return. Refactored Vis()/Unvis() into
go-mtree tar functionality as well.

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-07-25 16:41:06 -04:00
Stephen Chung
656e577ecc *: have gomtree always evaluate tar_time if it is present
if the keyword "tar_time" is present when evaluating
an Entry, gomtree should use the tar_time when evaluating
the "time" keyword as well. This commit also adds a test that
makes sure "tar_time" wins against "time" if both are present.
Some minor clean-ups as well, such as checking if KeywordFunc[keyword]
actually retrieves a function.

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-07-23 12:07:43 -04:00
bc6f3bf902 tar_time: treat time from tar archives special
Since the field in a tar header for each file only preserves seconds
precision, not nanosecond precision, let's handle it special. This will
allow for more custom case handling in Check()

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-07-23 12:07:43 -04:00
Stephen Chung
decc72b335 tar: create and validate a manifest from a tar stream
This commit contains added features to go-mtree that allows
user to create an mtree spec with '-T' option when specifying
a tar archive. Users can also validate an mtree spec against
a tar archive with an mtree spec. Also for the test archive,
there is a mixture of files, and folders (empty & non-empty),
and symlinks (broken & unbroken).

Signed-off-by: Stephen Chung <schung@redhat.com>
2016-07-23 12:07:43 -04:00
faa80931af *: refactoring to support streams
when creating a manifest from, or validating, a stream like a tar
archive, it requires thinking about some of the functions differently
than walking a directory tree.

This is the beginning of allowing for such features.

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2016-07-23 12:07:43 -04:00