fix file & folder perm eror

This commit is contained in:
tickstep 2022-06-16 22:30:12 +08:00
parent ba407cb74b
commit 8ac48bbda5
7 changed files with 15 additions and 15 deletions

View File

@ -173,7 +173,7 @@ func RunSync(fileDownloadParallel, fileUploadParallel int, downloadBlockSize, up
syncFolderRootPath := config.GetSyncDriveDir() syncFolderRootPath := config.GetSyncDriveDir()
if b, e := utils.PathExists(syncFolderRootPath); e == nil { if b, e := utils.PathExists(syncFolderRootPath); e == nil {
if !b { if !b {
os.MkdirAll(syncFolderRootPath, 0600) os.MkdirAll(syncFolderRootPath, 0755)
} }
} }

View File

@ -195,8 +195,8 @@ func (c *PanConfig) lazyOpenConfigFile() (err error) {
} }
c.fileMu.Lock() c.fileMu.Lock()
os.MkdirAll(filepath.Dir(c.configFilePath), 0700) os.MkdirAll(filepath.Dir(c.configFilePath), 0755)
c.configFile, err = os.OpenFile(c.configFilePath, os.O_CREATE|os.O_RDWR, 0600) c.configFile, err = os.OpenFile(c.configFilePath, os.O_CREATE|os.O_RDWR, 0755)
c.fileMu.Unlock() c.fileMu.Unlock()
if err != nil { if err != nil {

View File

@ -41,7 +41,7 @@ type boltKV struct {
} }
func openBoltDb(file string, bucket string) (SyncDb, error) { func openBoltDb(file string, bucket string) (SyncDb, error) {
db, err := bolt.Open(file + "_bolt.db", 0600, &bolt.Options{Timeout: 5 * time.Second}) db, err := bolt.Open(file+"_bolt.db", 0755, &bolt.Options{Timeout: 5 * time.Second})
if err != nil { if err != nil {
return nil, err return nil, err
@ -138,7 +138,7 @@ func (db *boltDB) First(prefix string) (*UploadedFileMeta, error) {
func (db *boltDB) Next(prefix string) (*UploadedFileMeta, error) { func (db *boltDB) Next(prefix string) (*UploadedFileMeta, error) {
data := &UploadedFileMeta{} data := &UploadedFileMeta{}
if _,ok := db.next[prefix]; ok { if _, ok := db.next[prefix]; ok {
if db.next[prefix].off >= db.next[prefix].size { if db.next[prefix].off >= db.next[prefix].size {
return nil, fmt.Errorf("no any more record") return nil, fmt.Errorf("no any more record")
} }
@ -165,7 +165,7 @@ func (db *boltDB) Put(key string, value *UploadedFileMeta) error {
} }
b := tx.Bucket([]byte(db.bucket)) b := tx.Bucket([]byte(db.bucket))
if b == nil { if b == nil {
b,err = tx.CreateBucket([]byte(db.bucket)) b, err = tx.CreateBucket([]byte(db.bucket))
if err != nil { if err != nil {
return err return err
} }
@ -182,4 +182,4 @@ func (db *boltDB) Close() error {
return db.db.Close() return db.db.Close()
} }
return nil return nil
} }

View File

@ -36,7 +36,7 @@ func NewBoltDb(dbFilePath string) *BoltDb {
} }
func (b *BoltDb) Open() (bool, error) { func (b *BoltDb) Open() (bool, error) {
db, err := bolt.Open(b.Path, 0600, &bolt.Options{Timeout: 5 * time.Second}) db, err := bolt.Open(b.Path, 0755, &bolt.Options{Timeout: 5 * time.Second})
if err != nil { if err != nil {
return false, err return false, err
} }

View File

@ -176,7 +176,7 @@ func (f *FileActionTask) downloadFile(ctx context.Context) error {
} }
localDir := path.Dir(f.syncItem.getLocalFileFullPath()) localDir := path.Dir(f.syncItem.getLocalFileFullPath())
if b, e := utils.PathExists(localDir); e == nil && !b { if b, e := utils.PathExists(localDir); e == nil && !b {
os.MkdirAll(localDir, 0600) os.MkdirAll(localDir, 0755)
time.Sleep(200 * time.Millisecond) time.Sleep(200 * time.Millisecond)
} }
writer, file, err := downloader.NewDownloaderWriterByFilename(f.syncItem.getLocalFileDownloadingFullPath(), os.O_CREATE|os.O_WRONLY, 0666) writer, file, err := downloader.NewDownloaderWriterByFilename(f.syncItem.getLocalFileDownloadingFullPath(), os.O_CREATE|os.O_WRONLY, 0666)

View File

@ -179,7 +179,7 @@ func (t *SyncTask) Stop() error {
func (t *SyncTask) panSyncDbFullPath() string { func (t *SyncTask) panSyncDbFullPath() string {
dir := path.Join(t.syncDbFolderPath, t.Id) dir := path.Join(t.syncDbFolderPath, t.Id)
if b, _ := utils.PathExists(dir); !b { if b, _ := utils.PathExists(dir); !b {
os.MkdirAll(dir, 0600) os.MkdirAll(dir, 0755)
} }
return path.Join(dir, "pan.bolt") return path.Join(dir, "pan.bolt")
} }
@ -188,7 +188,7 @@ func (t *SyncTask) panSyncDbFullPath() string {
func (t *SyncTask) localSyncDbFullPath() string { func (t *SyncTask) localSyncDbFullPath() string {
dir := path.Join(t.syncDbFolderPath, t.Id) dir := path.Join(t.syncDbFolderPath, t.Id)
if b, _ := utils.PathExists(dir); !b { if b, _ := utils.PathExists(dir); !b {
os.MkdirAll(dir, 0600) os.MkdirAll(dir, 0755)
} }
return path.Join(dir, "local.bolt") return path.Join(dir, "local.bolt")
} }
@ -197,7 +197,7 @@ func (t *SyncTask) localSyncDbFullPath() string {
func (t *SyncTask) syncFileDbFullPath() string { func (t *SyncTask) syncFileDbFullPath() string {
dir := path.Join(t.syncDbFolderPath, t.Id) dir := path.Join(t.syncDbFolderPath, t.Id)
if b, _ := utils.PathExists(dir); !b { if b, _ := utils.PathExists(dir); !b {
os.MkdirAll(dir, 0600) os.MkdirAll(dir, 0755)
} }
return path.Join(dir, "sync.bolt") return path.Join(dir, "sync.bolt")
} }

View File

@ -89,7 +89,7 @@ func (m *SyncTaskManager) parseConfigFile() error {
if b, _ := utils.PathExists(configFilePath); b != true { if b, _ := utils.PathExists(configFilePath); b != true {
//text := utils.ObjectToJsonStr(r, true) //text := utils.ObjectToJsonStr(r, true)
//ioutil.WriteFile(ConfigFilePath, []byte(text), 0600) //ioutil.WriteFile(ConfigFilePath, []byte(text), 0755)
return fmt.Errorf("备份配置文件不存在:" + m.ConfigFilePath()) return fmt.Errorf("备份配置文件不存在:" + m.ConfigFilePath())
} }
data, e := ioutil.ReadFile(configFilePath) data, e := ioutil.ReadFile(configFilePath)
@ -145,7 +145,7 @@ func (m *SyncTaskManager) Start() (bool, error) {
time.Sleep(200 * time.Millisecond) time.Sleep(200 * time.Millisecond)
} }
// save config file // save config file
ioutil.WriteFile(m.ConfigFilePath(), []byte(utils.ObjectToJsonStr(m.syncDriveConfig, true)), 0600) ioutil.WriteFile(m.ConfigFilePath(), []byte(utils.ObjectToJsonStr(m.syncDriveConfig, true)), 0755)
return true, nil return true, nil
} }
@ -162,6 +162,6 @@ func (m *SyncTaskManager) Stop() (bool, error) {
} }
// save config file // save config file
ioutil.WriteFile(m.ConfigFilePath(), []byte(utils.ObjectToJsonStr(m.syncDriveConfig, true)), 0600) ioutil.WriteFile(m.ConfigFilePath(), []byte(utils.ObjectToJsonStr(m.syncDriveConfig, true)), 0755)
return true, nil return true, nil
} }