added fs encryption overlay

This commit is contained in:
ston1th 2022-04-06 01:08:19 +02:00
commit fd1e8118a4
28 changed files with 3994 additions and 30 deletions

View file

@ -3,6 +3,7 @@
package fs
import (
"cachefs/pkg/chunk"
"cachefs/pkg/provider"
"context"
"encoding/json"
@ -80,7 +81,7 @@ func MetadataGenerator(file string, dst provider.FS) error {
if size <= blocks*512 {
md[strings.TrimPrefix(path, dst.Root())] = &Metadata{
Size: size,
Chunks: Chunks{{0, size}},
Chunks: chunk.Chunks{{0, size}},
}
}
return nil
@ -328,13 +329,21 @@ type Metadata struct {
name string `json:"-"`
Size int64 `json:"s"`
Atime int64 `json:"a"`
Chunks Chunks `json:"c"`
Chunks chunk.Chunks `json:"c"`
}
func (md *Metadata) Close() error {
md.mu.Lock()
defer md.mu.Unlock()
err := md.f.Close()
md.f = nil
return err
}
func (md *Metadata) Delete() error {
md.mu.Lock()
defer md.mu.Unlock()
md.Chunks = Chunks{}
md.Chunks = chunk.Chunks{}
md.f.Close()
md.f = nil
atomic.StoreInt64(&md.Atime, now())