Skip to content

Commit

Permalink
Complete implementation of moving files
Browse files Browse the repository at this point in the history
  • Loading branch information
gaowanliang committed Dec 21, 2020
1 parent 9356406 commit 8da762f
Show file tree
Hide file tree
Showing 337 changed files with 44,076 additions and 118 deletions.
242 changes: 133 additions & 109 deletions Telegram.go

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions i18n/active.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"uploadDownloadFolderFiles": "Upload files in the download folder",
"moveDownloadFolderFiles": "Move the files in the download folder",
"confirmDelete": "Sure to delete",
"cancel": "cancel",
"cancel": "Cancel",
"filesDeletedSuccessfully": "File was deleted successfully",
"noFilesFound": "There are no files in the folder",
"fileDirectoryIsAsFollows": "file directory is as follows:",
Expand All @@ -72,5 +72,9 @@
"onlyMinutes": "%d m ",
"onlySeconds": "%d s",
"UnableEstimate": "Unable to estimate",
"systemInfo": "\n*CPU:* %.2f%% *DISK:* %.2f%% *RAM:* %.2f%%\n*DL:* %s/s 📥 *UL:* %s/s 📤"
"systemInfo": "\n*CPU:* %.2f%% *DISK:* %.2f%% *RAM:* %.2f%%\n*DL:* %s/s 📥 *UL:* %s/s 📤",
"filesCopySuccessfully": "File successfully copied to moveFolder",
"pleaseSelectTheFileYouWantToCopy": "Please select the file you want to copy",
"confirmCopy": "Sure to copy",
"copyingTo": "`%s` *is being copied to* `%s`"
}
3 changes: 2 additions & 1 deletion i18n/active.zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,6 @@
"systemInfo": "\n*CPU:* %.2f%% *硬盘:* %.2f%% *内存:* %.2f%%\n*总下载速度:* %s/s 📥\n*总上传速度:* %s/s 📤",
"filesCopySuccessfully": "文件成功复制到moveFolder",
"pleaseSelectTheFileYouWantToCopy": "请选择您要复制的文件",
"confirmCopy": "确定复制"
"confirmCopy": "确定复制",
"copyingTo": "*正在将* `%s` *复制到* `%s`"
}
18 changes: 14 additions & 4 deletions i18n/active.zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
"paused": "暫停中",
"complete": "已完成",
"removed": "被移除",
"queryInformationFormat1": "GID:%s\n名稱: %s\n進度: %s\n大小: %s",
"queryInformationFormat2": "GID:%s\n名稱: %s\n狀態: %s\n進度: %s\n大小: %s",
"queryInformationFormat3": "GID:%s\n名稱: %s\n進度: %s\n大小: %s\n速度: %s/s",
"queryInformationFormat1": "*檔案名:* `%s`\n`%s`\n*已下載:* %s *共* %s\n*執行緒數:* %s\n*GID:* `%s`",
"queryInformationFormat2": "*檔案名:* `%s`\n*狀態:* %s\n`%s`\n*已下載:* %s *共* %s\n*執行緒數:* %s\n*GID:* `%s`",
"queryInformationFormat3": "*檔案名:* `%s`\n`%s`\n*已下載:* %s *共* %s\n*速度:* %s/s\n*剩餘時間:* %s\n*執行緒數:* %s\n*GID:* `%s`",
"ResumeAll": "恢復全部",
"StopAll": "停止全部",
"downloadFolderClear": "刪除下載檔案夾中所有檔",
Expand Down Expand Up @@ -66,5 +66,15 @@
"noFilesFound": "資料夾內沒有檔",
"fileDirectoryIsAsFollows": "的檔目錄如下:",
"pleaseSelectTheFileYouWantToDelete": "請選擇您要刪除的檔",
"pleaseSelectTheFileYouWantToDownload": "請選擇您要下載的檔"
"pleaseSelectTheFileYouWantToDownload": "請選擇您要下載的檔",
"onlyDays": "%d 天 ",
"onlyHours": "%d 小時 ",
"onlyMinutes": "%d 分鐘 ",
"onlySeconds": "%d 秒",
"UnableEstimate": "無法估計",
"systemInfo": "\n*CPU:* %.2f%% *硬碟:* %.2f%% *記憶體:* %.2f%%\n*總下載速度:* %s/s 📥\n*總上傳速度:* %s/s 📤",
"filesCopySuccessfully": "檔成功複製到moveFolder",
"pleaseSelectTheFileYouWantToCopy": "請選擇您要複製的檔",
"confirmCopy": "確定複製",
"copyingTo": "*正在將* `%s` *複製到* `%s`"
}
5 changes: 4 additions & 1 deletion upload/onedrive/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ module v2

go 1.14

require github.com/buger/jsonparser v1.0.0
require (
github.com/buger/jsonparser v1.0.0
github.com/shirou/gopsutil v3.20.11+incompatible // indirect
)
2 changes: 2 additions & 0 deletions upload/onedrive/go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
github.com/buger/jsonparser v1.0.0 h1:etJTGF5ESxjI0Ic2UaLQs2LQQpa8G9ykQScukbh4L8A=
github.com/buger/jsonparser v1.0.0/go.mod h1:tgcrVJ81GPSF0mz+0nu1Xaz0fazGPrmmJfJtxjbHhUQ=
github.com/shirou/gopsutil v3.20.11+incompatible h1:LJr4ZQK4mPpIV5gOa4jCOKOGb4ty4DZO54I4FGqIpto=
github.com/shirou/gopsutil v3.20.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
31 changes: 30 additions & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"net/http"
"os"
"path"
"path/filepath"
"regexp"
"strconv"
"strings"
Expand Down Expand Up @@ -151,15 +152,42 @@ func RemoveFiles(deleteFiles []string) {
}
func CopyFiles(srcFiles []string) {
destPath := info.MoveFolder
downloadFolder := info.DownloadFolder
if destPath[:len(destPath)-1] != "/" {
destPath += "/"
}
if downloadFolder[:len(downloadFolder)-1] != "/" {
downloadFolder += "/"
}
newMsg := sendAutoUpdateMessage()
for _, srcPath := range srcFiles {
if srcPath != info.DownloadFolder && srcPath != info.DownloadFolder+"/" {
newMsg(fmt.Sprintf(locText(""), srcPath, destPath+path.Base(srcPath)))
//log.Println(srcPath)
file1, err := os.Open(srcPath)
dropErr(err)
file2, err := os.OpenFile(destPath+path.Base(srcPath), os.O_WRONLY|os.O_CREATE, os.ModePerm)
s, err := os.Stat(srcPath)
if err == nil {
//log.Println(strings.ReplaceAll(srcPath, downloadFolder, destPath))
if s.IsDir() {
_, err := os.Stat(strings.ReplaceAll(srcPath, downloadFolder, destPath))
if err != nil {
err = os.MkdirAll(strings.ReplaceAll(srcPath, downloadFolder, destPath), os.ModePerm)
dropErr(err)
} else {
continue
}
} else {
paths, _ := filepath.Split(strings.ReplaceAll(srcPath, downloadFolder, destPath))
_, err := os.Stat(paths)
if err != nil {
err = os.MkdirAll(paths, os.ModePerm)
dropErr(err)
}
}
}

file2, err := os.OpenFile(strings.ReplaceAll(srcPath, downloadFolder, destPath), os.O_WRONLY|os.O_CREATE, os.ModePerm)
dropErr(err)
defer file1.Close()
defer file2.Close()
Expand All @@ -178,6 +206,7 @@ func CopyFiles(srcFiles []string) {
}
}
}
newMsg("close")
}

func GetAllFile(pathname string) ([][]string, int64) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions vendor/github.com/shirou/gopsutil/.github/labeler.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions vendor/github.com/shirou/gopsutil/.github/workflows/labeler.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions vendor/github.com/shirou/gopsutil/.github/workflows/shellcheck.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

91 changes: 91 additions & 0 deletions vendor/github.com/shirou/gopsutil/.github/workflows/test.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions vendor/github.com/shirou/gopsutil/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8da762f

Please sign in to comment.