diff --git a/models/repo.go b/models/repo.go index 5f90f97fc7..6b3df9fe0a 100755 --- a/models/repo.go +++ b/models/repo.go @@ -1133,6 +1133,9 @@ func IsUsableRepoAlias(name string) error { // CreateRepository creates a repository for the user/organization. func CreateRepository(ctx DBContext, doer, u *User, repo *Repository, opts ...CreateRepoOptions) (err error) { + if repo.Alias == "" { + repo.Alias = repo.Name + } repo.LowerAlias = strings.ToLower(repo.Alias) if err = IsUsableRepoName(repo.Name); err != nil { return err diff --git a/modules/storage/obs.go b/modules/storage/obs.go index a68bb7771d..8e6b4201b2 100755 --- a/modules/storage/obs.go +++ b/modules/storage/obs.go @@ -57,8 +57,8 @@ func ObsHasObject(path string) (bool, error) { return hasObject, nil } -func GetObsPartInfos(uuid string, uploadID string) (string, error) { - key := strings.TrimPrefix(path.Join(setting.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid, uuid)), "/") +func GetObsPartInfos(uuid, uploadID, fileName string) (string, error) { + key := strings.TrimPrefix(path.Join(setting.BasePath, path.Join(uuid[0:1], uuid[1:2], uuid, fileName)), "/") output, err := ObsCli.ListParts(&obs.ListPartsInput{ Bucket: setting.Bucket, diff --git a/modules/structs/repo.go b/modules/structs/repo.go index e290488a4a..6e9ece4b00 100755 --- a/modules/structs/repo.go +++ b/modules/structs/repo.go @@ -100,6 +100,10 @@ type CreateRepoOption struct { // required: true // unique: true Name string `json:"name" binding:"Required;AlphaDashDot;MaxSize(100)"` + // Alias of the repository to create + // required: false + // unique: true + Alias string `json:"alias" binding:"AlphaDashDotChinese;MaxSize(100)"` // Description of the repository to create Description string `json:"description" binding:"MaxSize(255)"` // Whether the repository is private diff --git a/modules/validation/binding.go b/modules/validation/binding.go index b608cdea23..d52919475c 100644 --- a/modules/validation/binding.go +++ b/modules/validation/binding.go @@ -128,6 +128,9 @@ func addAlphaDashDotChineseRule() { return strings.HasPrefix(rule, "AlphaDashDotChinese") }, IsValid: func(errs binding.Errors, name string, val interface{}) (bool, binding.Errors) { + if val == "" { + return true, errs + } if !ValidAlphaDashDotChinese(fmt.Sprintf("%v", val)) { errs.Add([]string{name}, ErrAlphaDashDotChinese, "ErrAlphaDashDotChinese") return false, errs diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index a724ebcc37..a85f88cb83 100755 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -232,6 +232,7 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR } repo, err := repo_service.CreateRepository(ctx.User, owner, models.CreateRepoOptions{ Name: opt.Name, + Alias: opt.Alias, Description: opt.Description, IssueLabels: opt.IssueLabels, Gitignores: opt.Gitignores, diff --git a/routers/repo/attachment.go b/routers/repo/attachment.go index 8443d6488e..c2d096416c 100755 --- a/routers/repo/attachment.go +++ b/routers/repo/attachment.go @@ -542,7 +542,7 @@ func GetSuccessChunks(ctx *context.Context) { log.Error("GetPartInfos failed:%v", err.Error()) } } else { - chunks, err = storage.GetObsPartInfos(fileChunk.UUID, fileChunk.UploadID) + chunks, err = storage.GetObsPartInfos(fileChunk.UUID, fileChunk.UploadID, fileName) if err != nil { log.Error("GetObsPartInfos failed:%v", err.Error()) } diff --git a/web_src/js/components/ObsUploader.vue b/web_src/js/components/ObsUploader.vue index 3b5bd3162b..b20594b86f 100755 --- a/web_src/js/components/ObsUploader.vue +++ b/web_src/js/components/ObsUploader.vue @@ -350,6 +350,16 @@ export default { etags[currentChunk] = res.headers.etag; } + async function uploadMinioNewMethod(url,e){ + var xhr = new XMLHttpRequest(); + xhr.open('PUT', url, false); + xhr.setRequestHeader('Content-Type', '') + xhr.send(e.target.result); + var etagValue = xhr.getResponseHeader('ETag'); + //console.log(etagValue); + etags[currentChunk] = etagValue; + } + async function updateChunk(currentChunk) { await axios.post( '/attachments/update_chunk', @@ -372,7 +382,7 @@ export default { await getUploadChunkUrl(currentChunk, partSize); if (urls[currentChunk] != '') { // 上传到minio - await uploadMinio(urls[currentChunk], e); + await uploadMinioNewMethod(urls[currentChunk], e); if (etags[currentChunk] != '') { // 更新数据库:分片上传结果 //await updateChunk(currentChunk);