package webfilesystem import ( "errors" "go.mongodb.org/mongo-driver/bson/primitive" ) // Deprecated func (fs *WebFileSystem) NewReadDeprecated(filePath string) (*WebFSFile, error) { splittedPath := fs.SplitPath(filePath) read := ReadStruct{ File: &WebFSFile{}, Filter: primitive.M{ "name": splittedPath[len(splittedPath)-1], }, } fileRaw, err := fs.ReadMongo(read) if err != nil { return nil, err } file := castToFile(fileRaw) return file, nil } // Deprecated func (fs *WebFileSystem) NewListDeprecated(dirPath string) ([]*WebFSFile, error) { dirFile, err := fs.NewReadDeprecated(dirPath) if err != nil { return nil, err } if dirFile.Type != "directory" { return nil, errors.New("file is not a directory") } fileData, err := castToDirectoryData(dirFile.Data) if err != nil { return nil, err } files := []*WebFSFile{} for _, child := range fileData.Children { file, err := fs.ReadByObjectID(child) if err != nil { println(err.Error()) continue } files = append(files, file) } return files, nil } func (fs *WebFileSystem) WriteFile(file *WebFSFile, parentPath string) error { fs.writeMongo(*file, parentPath) return errors.New("Not ready yet") }