@@ -10,12 +10,11 @@ import (
1010 "time"
1111
1212 "github.com/cozy/cozy-stack/model/vfs"
13+ "github.com/cozy/cozy-stack/pkg/consts"
1314 "github.com/cozy/cozy-stack/pkg/prefixer"
1415 "github.com/ncw/swift"
1516)
1617
17- const noteThumbFormat = "note"
18-
1918var unixEpochZero = time.Time {}
2019
2120// NewThumbsFsV2 creates a new thumb filesystem base on swift.
@@ -131,8 +130,8 @@ func (t *thumbsV2) ServeThumbContent(w http.ResponseWriter, req *http.Request, i
131130 return nil
132131}
133132
134- func (t * thumbsV2 ) CreateNoteThumb (id , mime string ) (vfs.ThumbFiler , error ) {
135- name := t .makeName (id , noteThumbFormat )
133+ func (t * thumbsV2 ) CreateNoteThumb (id , mime , format string ) (vfs.ThumbFiler , error ) {
134+ name := t .makeName (id , format )
136135 obj , err := t .c .ObjectCreate (t .container , name , true , "" , mime , nil )
137136 if err != nil {
138137 if _ , _ , errc := t .c .Container (t .container ); errc == swift .ContainerNotFound {
@@ -152,8 +151,8 @@ func (t *thumbsV2) CreateNoteThumb(id, mime string) (vfs.ThumbFiler, error) {
152151 return th , nil
153152}
154153
155- func (t * thumbsV2 ) OpenNoteThumb (id string ) (io.ReadCloser , error ) {
156- name := t .makeName (id , noteThumbFormat )
154+ func (t * thumbsV2 ) OpenNoteThumb (id , format string ) (io.ReadCloser , error ) {
155+ name := t .makeName (id , format )
157156 obj , _ , err := t .c .ObjectOpen (t .container , name , false , nil )
158157 if err == swift .ObjectNotFound {
159158 return nil , os .ErrNotExist
@@ -164,16 +163,24 @@ func (t *thumbsV2) OpenNoteThumb(id string) (io.ReadCloser, error) {
164163 return obj , nil
165164}
166165
167- func (t * thumbsV2 ) RemoveNoteThumb (id string ) error {
168- objName := t .makeName (id , noteThumbFormat )
169- return t .c .ObjectDelete (t .container , objName )
166+ func (t * thumbsV2 ) RemoveNoteThumb (id string , formats []string ) error {
167+ objNames := make ([]string , len (formats ))
168+ for i , format := range formats {
169+ objNames [i ] = t .makeName (id , format )
170+ }
171+ _ , err := t .c .BulkDelete (t .container , objNames )
172+ return err
170173}
171174
172175func (t * thumbsV2 ) ServeNoteThumbContent (w http.ResponseWriter , req * http.Request , id string ) error {
173- name := t .makeName (id , noteThumbFormat )
176+ name := t .makeName (id , consts . NoteImageThumbFormat )
174177 f , o , err := t .c .ObjectOpen (t .container , name , false , nil )
175178 if err != nil {
176- return wrapSwiftErr (err )
179+ name = t .makeName (id , consts .NoteImageOriginalFormat )
180+ f , o , err = t .c .ObjectOpen (t .container , name , false , nil )
181+ if err != nil {
182+ return wrapSwiftErr (err )
183+ }
177184 }
178185 defer f .Close ()
179186
0 commit comments