MCPcopy
hub / github.com/filebrowser/filebrowser / addVersionSuffix

Function addVersionSuffix

http/resource.go:278–294  ·  view source on GitHub ↗
(source string, afs afero.Fs)

Source from the content-addressed store, hash-verified

276}
277
278func addVersionSuffix(source string, afs afero.Fs) string {
279 counter := 1
280 dir, name := path.Split(source)
281 ext := filepath.Ext(name)
282 base := strings.TrimSuffix(name, ext)
283
284 for {
285 if _, err := afs.Stat(source); err != nil {
286 break
287 }
288 renamed := fmt.Sprintf("%s(%d)%s", base, counter, ext)
289 source = path.Join(dir, renamed)
290 counter++
291 }
292
293 return source
294}
295
296func writeFile(afs afero.Fs, dst string, in io.Reader, fileMode, dirMode fs.FileMode) (os.FileInfo, error) {
297 dir, _ := path.Split(dst)

Callers 1

resourcePatchHandlerFunction · 0.85

Calls 1

StatMethod · 0.45

Tested by

no test coverage detected