apkipa пре 2 месеци
родитељ
комит
4128039e3e
2 измењених фајлова са 16 додато и 12 уклоњено
  1. 1 1
      config/application.yaml
  2. 15 11
      main.go

+ 1 - 1
config/application.yaml

@@ -7,7 +7,7 @@ minio:
   accessKey: "25cSXPqzdHrPwJkSIRkM"
   secret: "FN3AhQaVo7z1wgvce3IWiI1CI68T02OVeSUKCeRf"
   bucket: "bucket"
-  host: "$(hostname).local:9010"
+  host: "localhost:9010"
 stck:
   host: "localhost:9000"
   table: "tsdb_cpp"

+ 15 - 11
main.go

@@ -58,6 +58,8 @@ type AppConfigDbEntry struct {
 	Value string
 }
 
+// TODO: 插入时先创建行,插入完后更新插入耗时
+
 // UploadRecord Represents a record of an uploaded stream. (A major upload task.)
 type UploadRecord struct {
 	Key       string `gorm:"primaryKey"`
@@ -409,21 +411,23 @@ func upload_one_part(app AppCtx, streamInfo *StreamMetadata, streamName string,
 			}
 
 			// Check if the part index is correct
-			if partIndex < 0 || partIndex >= streamInfo.PartsCount {
-				return fmt.Errorf("part index out of bounds: %d", partIndex)
+			if partIndex < 0 || (streamInfo.PartsCount != 0 && partIndex >= streamInfo.PartsCount) {
+				return fmt.Errorf("part index out of bounds: %d / %d", partIndex, streamInfo.PartsCount)
 			}
 
 			// Check if the part data size is correct
-			if partIndex < streamInfo.PartsCount-1 {
-				if len(partData) != streamInfo.PointsPerPart*8 {
-					return fmt.Errorf("part data size mismatch: %d", len(partData))
-				}
-			} else if partIndex == streamInfo.PartsCount-1 {
-				if len(partData) != (streamInfo.TotalPoints%streamInfo.PointsPerPart)*8 {
-					return fmt.Errorf("part data size mismatch: %d", len(partData))
+			if streamInfo.PartsCount != 0 {
+				if partIndex < streamInfo.PartsCount-1 {
+					if len(partData) != streamInfo.PointsPerPart*8 {
+						return fmt.Errorf("part data size mismatch: %d", len(partData))
+					}
+				} else if partIndex == streamInfo.PartsCount-1 {
+					if len(partData) != (streamInfo.TotalPoints%streamInfo.PointsPerPart)*8 {
+						return fmt.Errorf("part data size mismatch: %d", len(partData))
+					}
+				} else {
+					return fmt.Errorf("part index out of bounds: %d", partIndex)
 				}
-			} else {
-				return fmt.Errorf("part index out of bounds: %d", partIndex)
 			}
 		}
 		partPointsCount := len(partData) / 8