mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-22 08:42:32 -05:00
48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||
|
// Use of this source code is governed by a MIT-style
|
||
|
// license that can be found in the LICENSE file.
|
||
|
|
||
|
package setting
|
||
|
|
||
|
import (
|
||
|
"os"
|
||
|
"path/filepath"
|
||
|
|
||
|
"code.gitea.io/gitea/modules/log"
|
||
|
)
|
||
|
|
||
|
// Package registry settings
|
||
|
var (
|
||
|
Packages = struct {
|
||
|
Storage
|
||
|
Enabled bool
|
||
|
ChunkedUploadPath string
|
||
|
RegistryHost string
|
||
|
}{
|
||
|
Enabled: true,
|
||
|
}
|
||
|
)
|
||
|
|
||
|
func newPackages() {
|
||
|
sec := Cfg.Section("packages")
|
||
|
if err := sec.MapTo(&Packages); err != nil {
|
||
|
log.Fatal("Failed to map Packages settings: %v", err)
|
||
|
}
|
||
|
|
||
|
Packages.Storage = getStorage("packages", "", nil)
|
||
|
|
||
|
Packages.RegistryHost = Domain
|
||
|
if (Protocol == HTTP && HTTPPort != "80") || (Protocol == HTTPS && HTTPPort != "443") {
|
||
|
Packages.RegistryHost += ":" + HTTPPort
|
||
|
}
|
||
|
|
||
|
Packages.ChunkedUploadPath = filepath.ToSlash(sec.Key("CHUNKED_UPLOAD_PATH").MustString("tmp/package-upload"))
|
||
|
if !filepath.IsAbs(Packages.ChunkedUploadPath) {
|
||
|
Packages.ChunkedUploadPath = filepath.ToSlash(filepath.Join(AppDataPath, Packages.ChunkedUploadPath))
|
||
|
}
|
||
|
|
||
|
if err := os.MkdirAll(Packages.ChunkedUploadPath, os.ModePerm); err != nil {
|
||
|
log.Error("Unable to create chunked upload directory: %s (%v)", Packages.ChunkedUploadPath, err)
|
||
|
}
|
||
|
}
|