mirror of
https://github.com/fumiama/paper-manager.git
synced 2026-06-23 20:16:28 +08:00
优化analyze
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
"io"
|
"io"
|
||||||
@@ -23,6 +24,10 @@ import (
|
|||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrPaperFileExist = errors.New("paper file exist")
|
||||||
|
)
|
||||||
|
|
||||||
// AddFile from lst and copy it to analyzed path.
|
// AddFile from lst and copy it to analyzed path.
|
||||||
// The para reg must belong to a valid user
|
// The para reg must belong to a valid user
|
||||||
func (f *FileDatabase) AddFile(lstid int, reg *Regex, istemp bool, progress func(uint)) error {
|
func (f *FileDatabase) AddFile(lstid int, reg *Regex, istemp bool, progress func(uint)) error {
|
||||||
@@ -379,11 +384,14 @@ func (f *FileDatabase) AddFile(lstid int, reg *Regex, istemp bool, progress func
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
lst.Path = filebasepath + file.Class + ".docx"
|
|
||||||
lst.HasntAnalyzed = false
|
lst.HasntAnalyzed = false
|
||||||
lst.Desc = fmt.Sprintf("%s%v%v%v%c卷",
|
lst.Desc = fmt.Sprintf("%s%v%v%v%c卷",
|
||||||
file.Class, file.Year, file.Type.FirstSecond(), file.Type.MiddleFinal(), file.Type.AB(),
|
file.Class, file.Year, file.Type.FirstSecond(), file.Type.MiddleFinal(), file.Type.AB(),
|
||||||
)
|
)
|
||||||
|
lst.Path = filebasepath + lst.Desc + ".docx"
|
||||||
|
if utils.IsExist(lst.Path) {
|
||||||
|
return ErrPaperFileExist
|
||||||
|
}
|
||||||
dstf, err := os.Create(lst.Path)
|
dstf, err := os.Create(lst.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user