@@ -73,15 +73,16 @@ const (
73
73
// settings
74
74
var (
75
75
// AppVer settings
76
- AppVer string
77
- AppBuiltWith string
78
- AppName string
79
- AppURL string
80
- AppSubURL string
81
- AppSubURLDepth int // Number of slashes
82
- AppPath string
83
- AppDataPath string
84
- AppWorkPath string
76
+ AppVer string
77
+ AppBuiltWith string
78
+ AppName string
79
+ AppURL string
80
+ AppSubURL string
81
+ AppSubURLDepth int // Number of slashes
82
+ AppPath string
83
+ AppDataPath string
84
+ appDataUserPath string
85
+ AppWorkPath string
85
86
86
87
// Server settings
87
88
Protocol Scheme
@@ -701,7 +702,7 @@ func NewContext() {
701
702
if err = sec .MapTo (& LFS ); err != nil {
702
703
log .Fatal ("Failed to map LFS settings: %v" , err )
703
704
}
704
- LFS .ContentPath = sec .Key ("LFS_CONTENT_PATH" ).MustString (filepath .Join ("data" , "lfs" ))
705
+ LFS .ContentPath = sec .Key ("LFS_CONTENT_PATH" ).MustString (filepath .Join (appDataUserPath , "lfs" ))
705
706
forcePathSeparator (LFS .ContentPath )
706
707
LFS .ContentPath = suffixPathSeparator (LFS .ContentPath )
707
708
@@ -865,10 +866,10 @@ func NewContext() {
865
866
newRepository ()
866
867
867
868
sec = Cfg .Section ("picture" )
868
- AvatarUploadPath = sec .Key ("AVATAR_UPLOAD_PATH" ).MustString (path .Join ("data" , "avatars" ))
869
+ AvatarUploadPath = sec .Key ("AVATAR_UPLOAD_PATH" ).MustString (path .Join (appDataUserPath , "avatars" ))
869
870
forcePathSeparator (AvatarUploadPath )
870
871
AvatarUploadPath = suffixPathSeparator (AvatarUploadPath )
871
- RepositoryAvatarUploadPath = sec .Key ("REPOSITORY_AVATAR_UPLOAD_PATH" ).MustString (path .Join ("data" , "repo-avatars" ))
872
+ RepositoryAvatarUploadPath = sec .Key ("REPOSITORY_AVATAR_UPLOAD_PATH" ).MustString (path .Join (appDataUserPath , "repo-avatars" ))
872
873
forcePathSeparator (RepositoryAvatarUploadPath )
873
874
RepositoryAvatarUploadPath = suffixPathSeparator (RepositoryAvatarUploadPath )
874
875
RepositoryAvatarFallback = sec .Key ("REPOSITORY_AVATAR_FALLBACK" ).MustString ("none" )
@@ -1049,6 +1050,38 @@ func loadOrGenerateInternalToken(sec *ini.Section) string {
1049
1050
return token
1050
1051
}
1051
1052
1053
+ /*
1054
+ - Path represents AttachmentPath, AvatarUploadPath, RepositoryAvatarUploadPath or LFS.ContentPath
1055
+ - corresponding default PathValues are : "attachments", "avatars", "repo-avatars" & "lfs"
1056
+
1057
+ - appDataUserPath defaults to "data"
1058
+
1059
+ There may be two scenarios:
1060
+
1061
+ s1:
1062
+ Path is set in app.ini (rel or abs)
1063
+
1064
+ s2:
1065
+ Path is unset in app.ini
1066
+ Path <= appDataUserPath + Path
1067
+
1068
+ If appDataUserPath is set to abs in app.ini (via APP_DATA_PATH)
1069
+ Path is abs
1070
+ Otherwise
1071
+ Path is rel
1072
+
1073
+
1074
+ If Path is abs, the files will be read or stored to that abs Path even if the BUCKET_URL is set.
1075
+ Otherwise the following occurs,
1076
+
1077
+ if BUCKET_URL NOT SET {
1078
+ Path = file://{AppWorkPath}/{Path}
1079
+ } else {
1080
+ Path is used as Bucket prefix
1081
+ }
1082
+
1083
+ */
1084
+
1052
1085
// OpenBucket returns the bucket associated to path parameter
1053
1086
func OpenBucket (ctx context.Context , path string ) (* blob.Bucket , error ) {
1054
1087
if filepath .IsAbs (path ) {
0 commit comments