@@ -10,8 +10,8 @@ import (
1010
1111 "github.com/JojiiOfficial/gaw"
1212 "github.com/JojiiOfficial/shred"
13- "github.com/jinzhu/gorm"
1413 log "github.com/sirupsen/logrus"
14+ "gorm.io/gorm"
1515)
1616
1717var shredder = shred.Shredder {}
@@ -364,7 +364,7 @@ func (file *File) Save(db *gorm.DB) error {
364364
365365// GetCount get count if file
366366func (file File ) GetCount (db * gorm.DB , fileID uint ) (uint , error ) {
367- var c uint
367+ var c int64
368368
369369 fileFilter := File {
370370 Model : file .Model ,
@@ -396,7 +396,7 @@ func (file File) GetCount(db *gorm.DB, fileID uint) (uint, error) {
396396 // Execute statement
397397 err := del .Count (& c ).Error
398398
399- return c , err
399+ return uint ( c ) , err
400400}
401401
402402// GetPublicFile returns a file which is public
@@ -405,7 +405,7 @@ func GetPublicFile(db *gorm.DB, publicFilename string) (*File, bool, error) {
405405 err := db .Model (& File {}).Where ("public_filename = ? AND is_public=true" , publicFilename ).First (& file ).Error
406406 if err != nil {
407407 // Check error. Send server error if error is not "not found"
408- if gorm .IsRecordNotFoundError ( err ) {
408+ if err == gorm .ErrRecordNotFound {
409409 return nil , false , nil
410410 }
411411
@@ -495,7 +495,7 @@ func (file *File) SetUniqueFilename(db *gorm.DB) bool {
495495
496496 for i := 0 ; i < 7 ; i ++ {
497497 localName = gaw .RandString (40 )
498- var c int
498+ var c int64
499499 db .Model (& File {}).Where (& File {LocalName : localName }).Count (& c )
500500 if c == 0 {
501501 file .LocalName = localName
0 commit comments