(ctx context.Context, dir model.Obj, args model.ListArgs)
| 106 | } |
| 107 | |
| 108 | func (d *Crypt) List(ctx context.Context, dir model.Obj, args model.ListArgs) ([]model.Obj, error) { |
| 109 | path := dir.GetPath() |
| 110 | //return d.list(ctx, d.RemotePath, path) |
| 111 | //remoteFull |
| 112 | |
| 113 | objs, err := fs.List(ctx, d.getPathForRemote(path, true), &fs.ListArgs{NoLog: true}) |
| 114 | // the obj must implement the model.SetPath interface |
| 115 | // return objs, err |
| 116 | if err != nil { |
| 117 | return nil, err |
| 118 | } |
| 119 | |
| 120 | var result []model.Obj |
| 121 | for _, obj := range objs { |
| 122 | if obj.IsDir() { |
| 123 | name, err := d.cipher.DecryptDirName(obj.GetName()) |
| 124 | if err != nil { |
| 125 | //filter illegal files |
| 126 | continue |
| 127 | } |
| 128 | if !d.ShowHidden && strings.HasPrefix(name, ".") { |
| 129 | continue |
| 130 | } |
| 131 | objRes := model.Object{ |
| 132 | Name: name, |
| 133 | Size: 0, |
| 134 | Modified: obj.ModTime(), |
| 135 | IsFolder: obj.IsDir(), |
| 136 | Ctime: obj.CreateTime(), |
| 137 | // discarding hash as it's encrypted |
| 138 | } |
| 139 | result = append(result, &objRes) |
| 140 | } else { |
| 141 | thumb, ok := model.GetThumb(obj) |
| 142 | size, err := d.cipher.DecryptedSize(obj.GetSize()) |
| 143 | if err != nil { |
| 144 | //filter illegal files |
| 145 | continue |
| 146 | } |
| 147 | name, err := d.cipher.DecryptFileName(obj.GetName()) |
| 148 | if err != nil { |
| 149 | //filter illegal files |
| 150 | continue |
| 151 | } |
| 152 | if !d.ShowHidden && strings.HasPrefix(name, ".") { |
| 153 | continue |
| 154 | } |
| 155 | objRes := model.Object{ |
| 156 | Name: name, |
| 157 | Size: size, |
| 158 | Modified: obj.ModTime(), |
| 159 | IsFolder: obj.IsDir(), |
| 160 | Ctime: obj.CreateTime(), |
| 161 | // discarding hash as it's encrypted |
| 162 | } |
| 163 | if d.Thumbnail && thumb == "" { |
| 164 | thumbPath := stdpath.Join(args.ReqPath, ".thumbnails", name+".webp") |
| 165 | thumb = fmt.Sprintf("%s/d%s?sign=%s", |
nothing calls this directly
no test coverage detected