mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Add Ext format when exporting files.
This commit is contained in:
parent
8d10b91cf3
commit
3476d31e50
|
@ -6,6 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
@ -49,7 +50,7 @@ func init() {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
output = cmdExport.Flag.String("o", "", "output tar file name, must ends with .tar, or just a \"-\" for stdout")
|
output = cmdExport.Flag.String("o", "", "output tar file name, must ends with .tar, or just a \"-\" for stdout")
|
||||||
format = cmdExport.Flag.String("fileNameFormat", defaultFnFormat, "filename format, default to {{.Mime}}/{{.Id}}:{{.Name}}")
|
format = cmdExport.Flag.String("fileNameFormat", defaultFnFormat, "filename formatted with {{.Mime}} {{.Id}} {{.Name}} {{.Ext}}")
|
||||||
newer = cmdExport.Flag.String("newer", "", "export only files newer than this time, default is all files. Must be specified in RFC3339 without timezone")
|
newer = cmdExport.Flag.String("newer", "", "export only files newer than this time, default is all files. Must be specified in RFC3339 without timezone")
|
||||||
|
|
||||||
tarOutputFile *tar.Writer
|
tarOutputFile *tar.Writer
|
||||||
|
@ -159,6 +160,7 @@ type nameParams struct {
|
||||||
Id uint64
|
Id uint64
|
||||||
Mime string
|
Mime string
|
||||||
Key string
|
Key string
|
||||||
|
Ext string
|
||||||
}
|
}
|
||||||
|
|
||||||
func walker(vid storage.VolumeId, n *storage.Needle, version storage.Version) (err error) {
|
func walker(vid storage.VolumeId, n *storage.Needle, version storage.Version) (err error) {
|
||||||
|
@ -166,10 +168,12 @@ func walker(vid storage.VolumeId, n *storage.Needle, version storage.Version) (e
|
||||||
if tarOutputFile != nil {
|
if tarOutputFile != nil {
|
||||||
fileNameTemplateBuffer.Reset()
|
fileNameTemplateBuffer.Reset()
|
||||||
if err = fileNameTemplate.Execute(fileNameTemplateBuffer,
|
if err = fileNameTemplate.Execute(fileNameTemplateBuffer,
|
||||||
nameParams{Name: string(n.Name),
|
nameParams{
|
||||||
|
Name: string(n.Name),
|
||||||
Id: n.Id,
|
Id: n.Id,
|
||||||
Mime: string(n.Mime),
|
Mime: string(n.Mime),
|
||||||
Key: key,
|
Key: key,
|
||||||
|
Ext: filepath.Ext(string(n.Name)),
|
||||||
},
|
},
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue