Move get file extension logic to util (#1670)
* Move get file extension logic to util * Update TestGetFileExtension to use fake file * Add more test cases to TestGetFileExtension
This commit is contained in:
1 parent
647fa469fb
commit
63815aaa75
5 files changed
+71
-23
No files matched your search
@@ -37,7 +37,7 @@ func copySize(srcs []string) (int64, error) {
|
||||
}
|
||||
|
||||
func copyFile(src, dst string, preserve []string, info os.FileInfo, nums chan int64) error {
|
||||
var dst_mode os.FileMode = 0666
|
||||
var dst_mode os.FileMode = 0o666
|
||||
preserve_timestamps := false
|
||||
for _, s := range preserve {
|
||||
switch s {
|
||||
@@ -107,9 +107,9 @@ func copyAll(srcs []string, dstDir string, preserve []string) (nums chan int64,
|
||||
file := filepath.Base(src)
|
||||
dst := filepath.Join(dstDir, file)
|
||||
|
||||
_, err := os.Lstat(dst)
|
||||
lstat, err := os.Lstat(dst)
|
||||
if !os.IsNotExist(err) {
|
||||
ext := filepath.Ext(file)
|
||||
ext := getFileExtension(lstat)
|
||||
basename := file[:len(file)-len(ext)]
|
||||
var newPath string
|
||||
for i := 1; !os.IsNotExist(err); i++ {
|
||||
|
||||
Reference in new issue
Block a user