Add resources.Copy

Implemented by most Resource objects, but not Page (for now).

Fixes #9313
This commit is contained in:
Bjørn Erik Pedersen
2022-05-24 09:34:36 +02:00
parent 6f7fbe03b1
commit cd0112a05a
8 changed files with 169 additions and 13 deletions

View File

@@ -51,6 +51,13 @@ func New(rs *resources.Spec) *Client {
}
}
// Copy copies r to the new targetPath.
func (c *Client) Copy(r resource.Resource, targetPath string) (resource.Resource, error) {
return c.rs.ResourceCache.GetOrCreate(resources.ResourceCacheKey(targetPath), func() (resource.Resource, error) {
return resources.Copy(r, targetPath), nil
})
}
// Get creates a new Resource by opening the given filename in the assets filesystem.
func (c *Client) Get(filename string) (resource.Resource, error) {
filename = filepath.Clean(filename)