Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHamidreza Ghavami <hamid.r.gh.1998@gmail.com>2023-05-05 21:21:39 +0300
committerHamidreza Ghavami <hamid.r.gh.1998@gmail.com>2023-05-05 21:21:39 +0300
commit85c715a2f610aad306e1ef9c3856f2264b01124e (patch)
treea77176b220d35c96629b0c4b648639080a27cbd4 /database/db.go
parent55c1fe26fba88210f0b24fcdeaf3cff6f779e741 (diff)
update axios-init and db.go
Diffstat (limited to 'database/db.go')
-rw-r--r--database/db.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/database/db.go b/database/db.go
index ae42a6de..d5caa702 100644
--- a/database/db.go
+++ b/database/db.go
@@ -1,6 +1,8 @@
package database
import (
+ "bytes"
+ "io"
"io/fs"
"os"
"path"
@@ -104,3 +106,13 @@ func GetDB() *gorm.DB {
func IsNotFound(err error) bool {
return err == gorm.ErrRecordNotFound
}
+
+func IsSQLiteDB(file io.Reader) (bool, error) {
+ signature := []byte("SQLite format 3\x00")
+ buf := make([]byte, len(signature))
+ _, err := file.Read(buf)
+ if err != nil {
+ return false, err
+ }
+ return bytes.Equal(buf, signature), nil
+}