|
@@ -120,10 +120,15 @@ func NewFileSystemHandler(option FileSystemOption) (*FileSystemHandler, error) {
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
//Create the fsdb for this handler
|
|
//Create the fsdb for this handler
|
|
- fsdb, err := db.NewDatabase(filepath.ToSlash(filepath.Join(filepath.Clean(option.Path), "aofs.db")), false)
|
|
|
|
- if err != nil {
|
|
|
|
- return &FileSystemHandler{}, errors.New("Unable to create fsdb inside the target path. Is the directory read only?")
|
|
|
|
|
|
+ var fsdb *db.Database = nil
|
|
|
|
+ if option.Access != "readonly" {
|
|
|
|
+ dbp, err := db.NewDatabase(filepath.ToSlash(filepath.Join(filepath.Clean(option.Path), "aofs.db")), false)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return &FileSystemHandler{}, errors.New("Unable to create fsdb inside the target path. Is the directory read only?")
|
|
|
|
+ }
|
|
|
|
+ fsdb = dbp
|
|
}
|
|
}
|
|
|
|
|
|
return &FileSystemHandler{
|
|
return &FileSystemHandler{
|
|
@@ -164,6 +169,10 @@ func NewFileSystemHandler(option FileSystemOption) (*FileSystemHandler, error) {
|
|
|
|
|
|
//Create a file ownership record
|
|
//Create a file ownership record
|
|
func (fsh *FileSystemHandler) CreateFileRecord(realpath string, owner string) error {
|
|
func (fsh *FileSystemHandler) CreateFileRecord(realpath string, owner string) error {
|
|
|
|
+ if fsh.FilesystemDatabase == nil {
|
|
|
|
+ //Not supported file system type
|
|
|
|
+ return errors.New("Not supported filesystem type")
|
|
|
|
+ }
|
|
rpabs, _ := filepath.Abs(realpath)
|
|
rpabs, _ := filepath.Abs(realpath)
|
|
fsrabs, _ := filepath.Abs(fsh.Path)
|
|
fsrabs, _ := filepath.Abs(fsh.Path)
|
|
reldir, err := filepath.Rel(fsrabs, rpabs)
|
|
reldir, err := filepath.Rel(fsrabs, rpabs)
|
|
@@ -178,6 +187,11 @@ func (fsh *FileSystemHandler) CreateFileRecord(realpath string, owner string) er
|
|
|
|
|
|
//Read the owner of a file
|
|
//Read the owner of a file
|
|
func (fsh *FileSystemHandler) GetFileRecord(realpath string) (string, error) {
|
|
func (fsh *FileSystemHandler) GetFileRecord(realpath string) (string, error) {
|
|
|
|
+ if fsh.FilesystemDatabase == nil {
|
|
|
|
+ //Not supported file system type
|
|
|
|
+ return "", errors.New("Not supported filesystem type")
|
|
|
|
+ }
|
|
|
|
+
|
|
rpabs, _ := filepath.Abs(realpath)
|
|
rpabs, _ := filepath.Abs(realpath)
|
|
fsrabs, _ := filepath.Abs(fsh.Path)
|
|
fsrabs, _ := filepath.Abs(fsh.Path)
|
|
reldir, err := filepath.Rel(fsrabs, rpabs)
|
|
reldir, err := filepath.Rel(fsrabs, rpabs)
|
|
@@ -196,6 +210,11 @@ func (fsh *FileSystemHandler) GetFileRecord(realpath string) (string, error) {
|
|
|
|
|
|
//Delete a file ownership record
|
|
//Delete a file ownership record
|
|
func (fsh *FileSystemHandler) DeleteFileRecord(realpath string) error {
|
|
func (fsh *FileSystemHandler) DeleteFileRecord(realpath string) error {
|
|
|
|
+ if fsh.FilesystemDatabase == nil {
|
|
|
|
+ //Not supported file system type
|
|
|
|
+ return errors.New("Not supported filesystem type")
|
|
|
|
+ }
|
|
|
|
+
|
|
rpabs, _ := filepath.Abs(realpath)
|
|
rpabs, _ := filepath.Abs(realpath)
|
|
fsrabs, _ := filepath.Abs(fsh.Path)
|
|
fsrabs, _ := filepath.Abs(fsh.Path)
|
|
reldir, err := filepath.Rel(fsrabs, rpabs)
|
|
reldir, err := filepath.Rel(fsrabs, rpabs)
|