1
0
mirror of https://github.com/fumiama/paper-manager.git synced 2026-06-23 03:50:33 +08:00

implement chkdup & optimize file

This commit is contained in:
源文雨
2023-05-04 19:58:44 +08:00
parent e9c4b9975f
commit f5c5d0d526
11 changed files with 197 additions and 29 deletions

View File

@@ -31,7 +31,7 @@ type filelist struct {
Per uint `json:"percent"`
}
func getFileList(count int, istemp bool) ([]filelist, error) {
func getFileList(count int, istemp *bool) ([]filelist, error) {
lst, err := global.FileDB.ListUploadedFile(istemp)
if err != nil && err != sql.ErrNullResult {
return nil, err
@@ -149,7 +149,12 @@ func init() {
writeresult(w, codeError, nil, errInvalidToken.Error(), typeError)
return
}
istemp := r.URL.Query().Get("permanent") != "true"
istemp := (*bool)(nil)
permanent := r.URL.Query().Get("permanent")
if permanent != "" {
b := permanent != "true"
istemp = &b
}
count := -1
var err error
countstr := r.URL.Query().Get("count")

View File

@@ -83,11 +83,14 @@ func (f *FileDatabase) SaveFileToTemp(uploader int, file io.Reader, name string)
}
// ListUploadedFile will select all file that HasntAnalyzed && IsTemp or !HasntAnalyzed && !IsTemp
func (f *FileDatabase) ListUploadedFile(istemp bool) (lst []*List, err error) {
func (f *FileDatabase) ListUploadedFile(istemp *bool) (lst []*List, err error) {
q := ""
if istemp {
switch {
case istemp == nil:
q = "ORDER BY UpTime DESC"
case *istemp:
q = "WHERE IsTemp ORDER BY UpTime DESC"
} else {
default:
q = "WHERE (HasntAnalyzed AND IsTemp) OR (NOT HasntAnalyzed AND NOT IsTemp) ORDER BY UpTime DESC"
}
f.mu.RLock()