|
@@ -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
|