mirror of
https://github.com/vbatts/tar-split.git
synced 2024-11-16 05:18:38 +00:00
d214ab47e8
This removes all of the special handling code for both TarCheck() and Check() so that everything now uses the new (generic) Compare() code. In addition, the tests had to be modified to reflect the new classes of errors. Signed-off-by: Aleksa Sarai <asarai@suse.de>
31 lines
1.1 KiB
Go
31 lines
1.1 KiB
Go
package mtree
|
|
|
|
// Check a root directory path against the DirectoryHierarchy, regarding only
|
|
// the available keywords from the list and each entry in the hierarchy.
|
|
// If keywords is nil, the check all present in the DirectoryHierarchy
|
|
//
|
|
// This is equivalent to creating a new DirectoryHierarchy with Walk(root, nil,
|
|
// keywords) and then doing a Compare(dh, newDh, keywords).
|
|
func Check(root string, dh *DirectoryHierarchy, keywords []string) ([]InodeDelta, error) {
|
|
if keywords == nil {
|
|
keywords = CollectUsedKeywords(dh)
|
|
}
|
|
|
|
newDh, err := Walk(root, nil, keywords)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
// TODO: Handle tar_time, if necessary.
|
|
return Compare(dh, newDh, keywords)
|
|
}
|
|
|
|
// TarCheck is the tar equivalent of checking a file hierarchy spec against a
|
|
// tar stream to determine if files have been changed. This is precisely
|
|
// equivalent to Compare(dh, tarDH, keywords).
|
|
func TarCheck(tarDH, dh *DirectoryHierarchy, keywords []string) ([]InodeDelta, error) {
|
|
if keywords == nil {
|
|
keywords = CollectUsedKeywords(dh)
|
|
}
|
|
return Compare(dh, tarDH, keywords)
|
|
}
|