archive: accept a FileLister in the AddItems method
This commit is contained in:
@@ -18,6 +18,7 @@ import (
|
|||||||
|
|
||||||
"github.com/cavaliercoder/go-cpio"
|
"github.com/cavaliercoder/go-cpio"
|
||||||
"github.com/klauspost/pgzip"
|
"github.com/klauspost/pgzip"
|
||||||
|
"gitlab.com/postmarketOS/postmarketos-mkinitfs/internal/filelist"
|
||||||
"gitlab.com/postmarketOS/postmarketos-mkinitfs/internal/misc"
|
"gitlab.com/postmarketOS/postmarketos-mkinitfs/internal/misc"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -119,9 +120,13 @@ func (archive *Archive) Write(path string, mode os.FileMode) error {
|
|||||||
|
|
||||||
// Adds the given items in the map to the archive. The map format is {source path:dest path}.
|
// Adds the given items in the map to the archive. The map format is {source path:dest path}.
|
||||||
// Internally this just calls AddItem on each key,value pair in the map.
|
// Internally this just calls AddItem on each key,value pair in the map.
|
||||||
func (archive *Archive) AddItems(paths map[string]string) error {
|
func (archive *Archive) AddItems(f filelist.FileLister) error {
|
||||||
for s, d := range paths {
|
list, err := f.List()
|
||||||
if err := archive.AddItem(s, d); err != nil {
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for i := range list.IterItems() {
|
||||||
|
if err := archive.AddItem(i.Source, i.Dest); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user