zhangxinlei1996 пре 1 година
родитељ
комит
ca72a5192b
2 измењених фајлова са 30 додато и 14 уклоњено
  1. 17 3
      fileUploadCount/tj.go
  2. 13 11
      yunpanWeb/service/config/config.go

+ 17 - 3
fileUploadCount/tj.go

@@ -16,6 +16,9 @@ func Statistics() {
 	path = "云盘管理/日志/华软"
 	getRemoteFilePath(webdav, user, secert, path, path)
 
+	// path := "云盘管理/日志/张金石"
+	// getRemoteFilePath(webdav, user, secert, path, path)
+
 }
 
 // 获取数据目录
@@ -31,14 +34,21 @@ func getRemoteFilePath(webdav, user, secert, remote, company string) {
 		log.Fatal(err)
 	}
 
+	m := map[string]bool{}
+
 	// 遍历目录结构
 	for _, entry := range entries {
 		// log.Println(remote + "/" + entry.Name())
 		if entry.IsDir() {
 			// 如果是目录,则递归遍历子目录
-			success = readDirRecursive(client, remote+"/"+entry.Name(), success)
+			success = readDirRecursive(client, remote+"/"+entry.Name(), success, m)
 		} else {
+
 			pth := rename(client, remote+"/"+entry.Name())
+			if m[pth] {
+				continue
+			}
+			m[pth] = true
 			log.Println(pth)
 			info, _ := client.Read(pth)
 			str := string(info)
@@ -50,7 +60,7 @@ func getRemoteFilePath(webdav, user, secert, remote, company string) {
 }
 
 // 递归遍历目录结构
-func readDirRecursive(client *gowebdav.Client, path string, success int) int {
+func readDirRecursive(client *gowebdav.Client, path string, success int, m map[string]bool) int {
 	entries, err := client.ReadDir(path)
 	if err != nil {
 		log.Fatal(err)
@@ -58,7 +68,7 @@ func readDirRecursive(client *gowebdav.Client, path string, success int) int {
 	for _, entry := range entries {
 		if entry.IsDir() {
 			// 如果是目录,则递归遍历子目录
-			success = readDirRecursive(client, path+"/"+entry.Name(), success)
+			success = readDirRecursive(client, path+"/"+entry.Name(), success, m)
 		} else {
 			file_path := path + "/" + entry.Name()
 			if !strings.Contains(file_path, *date) {
@@ -66,6 +76,10 @@ func readDirRecursive(client *gowebdav.Client, path string, success int) int {
 			}
 			//计算成功
 			pth := rename(client, file_path)
+			if m[pth] {
+				continue
+			}
+			m[pth] = true
 			info, _ := client.Read(pth)
 			str := string(info)
 			// log.Println(str)

+ 13 - 11
yunpanWeb/service/config/config.go

@@ -49,20 +49,22 @@ func init() {
 				MongodbAddr: Sysconfig.Mongodb.Main.Address,
 				Size:        Sysconfig.Mongodb.Main.Size,
 				DbName:      Sysconfig.Mongodb.Main.DbName,
+				UserName:    Sysconfig.Mongodb.Main.UserName,
+				Password:    Sysconfig.Mongodb.Main.Password,
 			}
 			MQFW.InitPool()
 		}
-		if Sysconfig.Mongodb.Log != nil {
-			log.Println("初始化 mongodb log")
-			Mgo_Log = mg.MongodbSim{
-				MongodbAddr: Sysconfig.Mongodb.Log.Address,
-				Size:        Sysconfig.Mongodb.Log.Size,
-				DbName:      Sysconfig.Mongodb.Log.DbName,
-				UserName:    Sysconfig.Mongodb.Log.UserName,
-				Password:    Sysconfig.Mongodb.Log.Password,
-			}
-			Mgo_Log.InitPool()
-		}
+		// if Sysconfig.Mongodb.Log != nil {
+		// 	log.Println("初始化 mongodb log")
+		// 	Mgo_Log = mg.MongodbSim{
+		// 		MongodbAddr: Sysconfig.Mongodb.Log.Address,
+		// 		Size:        Sysconfig.Mongodb.Log.Size,
+		// 		DbName:      Sysconfig.Mongodb.Log.DbName,
+		// 		UserName:    Sysconfig.Mongodb.Log.UserName,
+		// 		Password:    Sysconfig.Mongodb.Log.Password,
+		// 	}
+		// 	Mgo_Log.InitPool()
+		// }
 
 		if Sysconfig.Secert != "" {
 			log.Println("初始化云盘")