Skip to content

Commit d660e50

Browse files
authored
Merge branch 'main' into main
2 parents d538cd1 + bb7e061 commit d660e50

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1810
-270
lines changed

cmd/serv.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,15 @@ func runServ(c *cli.Context) error {
296296
gitcmd = exec.CommandContext(ctx, verb, repoPath)
297297
}
298298

299+
// Check if setting.RepoRootPath exists. It could be the case that it doesn't exist, this can happen when
300+
// `[repository]` `ROOT` is a relative path and $GITEA_WORK_DIR isn't passed to the SSH connection.
301+
if _, err := os.Stat(setting.RepoRootPath); err != nil {
302+
if os.IsNotExist(err) {
303+
return fail("Incorrect configuration.",
304+
"Directory `[repository]` `ROOT` was not found, please check if $GITEA_WORK_DIR is passed to the SSH connection or make `[repository]` `ROOT` an absolute value.")
305+
}
306+
}
307+
299308
gitcmd.Dir = setting.RepoRootPath
300309
gitcmd.Stdout = os.Stdout
301310
gitcmd.Stdin = os.Stdin

custom/conf/app.example.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ RUN_MODE = ; prod
237237
;; PPROF_DATA_PATH, use an absolute path when you start gitea as service
238238
;PPROF_DATA_PATH = data/tmp/pprof
239239
;;
240-
;; Landing page, can be "home", "explore", "organizations" or "login"
240+
;; Landing page, can be "home", "explore", "organizations", "login", or any URL such as "/org/repo" or even "https://anotherwebsite.com"
241241
;; The "login" choice is not a security measure but just a UI flow change, use REQUIRE_SIGNIN_VIEW to force users to log in.
242242
;LANDING_PAGE = home
243243
;;
@@ -2117,6 +2117,7 @@ PATH =
21172117
;[i18n]
21182118
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
21192119
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2120+
;; The first locale will be used as the default if user browser's language doesn't match any locale in the list.
21202121
;LANGS = en-US,zh-CN,zh-HK,zh-TW,de-DE,fr-FR,nl-NL,lv-LV,ru-RU,uk-UA,ja-JP,es-ES,pt-BR,pt-PT,pl-PL,bg-BG,it-IT,fi-FI,tr-TR,cs-CZ,sr-SP,sv-SE,ko-KR,el-GR,fa-IR,hu-HU,id-ID,ml-IN
21212122
;NAMES = English,简体中文,繁體中文(香港),繁體中文(台灣),Deutsch,français,Nederlands,latviešu,русский,Українська,日本語,español,português do Brasil,Português de Portugal,polski,български,italiano,suomi,Türkçe,čeština,српски,svenska,한국어,ελληνικά,فارسی,magyar nyelv,bahasa Indonesia,മലയാളം
21222123

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
300300
- `ENABLE_GZIP`: **false**: Enable gzip compression for runtime-generated content, static resources excluded.
301301
- `ENABLE_PPROF`: **false**: Application profiling (memory and cpu). For "web" command it listens on localhost:6060. For "serv" command it dumps to disk at `PPROF_DATA_PATH` as `(cpuprofile|memprofile)_<username>_<temporary id>`
302302
- `PPROF_DATA_PATH`: **data/tmp/pprof**: `PPROF_DATA_PATH`, use an absolute path when you start Gitea as service
303-
- `LANDING_PAGE`: **home**: Landing page for unauthenticated users \[home, explore, organizations, login\].
304-
303+
- `LANDING_PAGE`: **home**: Landing page for unauthenticated users \[home, explore, organizations, login, **custom**\]. Where custom would instead be any URL such as "/org/repo" or even `https://anotherwebsite.com`
305304
- `LFS_START_SERVER`: **false**: Enables Git LFS support.
306305
- `LFS_CONTENT_PATH`: **%(APP_DATA_PATH)/lfs**: Default LFS content path. (if it is on local storage.) **DEPRECATED** use settings in `[lfs]`.
307306
- `LFS_JWT_SECRET`: **\<empty\>**: LFS authentication secret, change this a unique string.
@@ -997,7 +996,8 @@ Default templates for project boards:
997996

998997
## i18n (`i18n`)
999998

1000-
- `LANGS`: **en-US,zh-CN,zh-HK,zh-TW,de-DE,fr-FR,nl-NL,lv-LV,ru-RU,ja-JP,es-ES,pt-BR,pt-PT,pl-PL,bg-BG,it-IT,fi-FI,tr-TR,cs-CZ,sr-SP,sv-SE,ko-KR,el-GR,fa-IR,hu-HU,id-ID,ml-IN**: List of locales shown in language selector
999+
- `LANGS`: **en-US,zh-CN,zh-HK,zh-TW,de-DE,fr-FR,nl-NL,lv-LV,ru-RU,ja-JP,es-ES,pt-BR,pt-PT,pl-PL,bg-BG,it-IT,fi-FI,tr-TR,cs-CZ,sr-SP,sv-SE,ko-KR,el-GR,fa-IR,hu-HU,id-ID,ml-IN**:
1000+
List of locales shown in language selector. The first locale will be used as the default if user browser's language doesn't match any locale in the list.
10011001
- `NAMES`: **English,简体中文,繁體中文(香港),繁體中文(台灣),Deutsch,français,Nederlands,latviešu,русский,日本語,español,português do Brasil,Português de Portugal,polski,български,italiano,suomi,Türkçe,čeština,српски,svenska,한국어,ελληνικά,فارسی,magyar nyelv,bahasa Indonesia,മലയാളം**: Visible names corresponding to the locales
10021002

10031003
## U2F (`U2F`) **DEPRECATED**

docs/content/doc/advanced/customizing-gitea.en-us.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ LANGS = en-US,foo-BAR
299299
NAMES = English,FooBar
300300
```
301301

302+
The first locale will be used as the default if user browser's language doesn't match any locale in the list.
303+
302304
Locales may change between versions, so keeping track of your customized locales is highly encouraged.
303305

304306
### Readmes

docs/content/doc/advanced/logging-documentation.en-us.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ MODE = console
287287
LEVEL = debug ; please set the level to debug when we are debugging a problem
288288
ROUTER = console
289289
COLORIZE = false ; this can be true if you can strip out the ansi coloring
290+
ENABLE_SSH_LOG = true ; shows logs related to git over SSH.
290291
```
291292

292293
Sometimes it will be helpful get some specific `TRACE` level logging restricted
@@ -445,7 +446,7 @@ Gitea includes built-in log rotation, which should be enough for most deployment
445446
- Disable built-in log rotation by setting `LOG_ROTATE` to `false` in your `app.ini`.
446447
- Install `logrotate`.
447448
- Configure `logrotate` to match your deployment requirements, see `man 8 logrotate` for configuration syntax details. In the `postrotate/endscript` block send Gitea a `USR1` signal via `kill -USR1` or `kill -10` to the `gitea` process itself, or run `gitea manager logging release-and-reopen` (with the appropriate environment). Ensure that your configurations apply to all files emitted by Gitea loggers as described in the above sections.
448-
- Always do `logrotate /etc/logrotate.conf --debug` to test your configurations.
449+
- Always do `logrotate /etc/logrotate.conf --debug` to test your configurations.
449450
- If you are using docker and are running from outside of the container you can use `docker exec -u $OS_USER $CONTAINER_NAME sh -c 'gitea manager logging release-and-reopen'` or `docker exec $CONTAINER_NAME sh -c '/bin/s6-svc -1 /etc/s6/gitea/'` or send `USR1` directly to the Gitea process itself.
450451

451452
The next `logrotate` jobs will include your configurations, so no restart is needed. You can also immediately reload `logrotate` with `logrotate /etc/logrotate.conf --force`.

go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ require (
7878
github.com/stretchr/testify v1.7.0
7979
github.com/syndtr/goleveldb v1.0.0
8080
github.com/tstranex/u2f v1.0.0
81-
github.com/unknwon/i18n v0.0.0-20210904045753-ff3a8617e361
82-
github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae
8381
github.com/unrolled/render v1.4.1
8482
github.com/urfave/cli v1.22.5
8583
github.com/xanzy/go-gitlab v0.58.0

go.sum

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,10 +1503,6 @@ github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0o
15031503
github.com/unknwon/com v0.0.0-20190804042917-757f69c95f3e/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM=
15041504
github.com/unknwon/com v1.0.1 h1:3d1LTxD+Lnf3soQiD4Cp/0BRB+Rsa/+RTvz8GMMzIXs=
15051505
github.com/unknwon/com v1.0.1/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM=
1506-
github.com/unknwon/i18n v0.0.0-20210904045753-ff3a8617e361 h1:4Ij5sX4JEzCCY/CCl8trJHey1tPsIDomYTZf145GKk0=
1507-
github.com/unknwon/i18n v0.0.0-20210904045753-ff3a8617e361/go.mod h1:+5rDk6sDGpl3azws3O+f+GpFSyN9GVr0K8cvQLQM2ZQ=
1508-
github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae h1:ihaXiJkaca54IaCSnEXtE/uSZOmPxKZhDfVLrzZLFDs=
1509-
github.com/unknwon/paginater v0.0.0-20200328080006-042474bd0eae/go.mod h1:1fdkY6xxl6ExVs2QFv7R0F5IRZHKA8RahhB9fMC9RvM=
15101506
github.com/unrolled/render v1.4.1 h1:VdpMc2YkAOWzbmC/P2yoHhRDXgsaCQHcTJ1KK6SNCA4=
15111507
github.com/unrolled/render v1.4.1/go.mod h1:cK4RSTTVdND5j9EYEc0LAMOvdG11JeiKjyjfyZRvV2w=
15121508
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
@@ -2272,7 +2268,6 @@ gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AW
22722268
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw=
22732269
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
22742270
gopkg.in/ini.v1 v1.44.2/go.mod h1:M3Cogqpuv0QCi3ExAY5V4uOt4qb/R3xZubo9m8lK5wg=
2275-
gopkg.in/ini.v1 v1.46.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
22762271
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
22772272
gopkg.in/ini.v1 v1.57.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
22782273
gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=

integrations/api_packages_test.go

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@ import (
99
"fmt"
1010
"net/http"
1111
"testing"
12+
"time"
1213

13-
"code.gitea.io/gitea/models/packages"
14+
"code.gitea.io/gitea/models/db"
15+
packages_model "code.gitea.io/gitea/models/packages"
16+
container_model "code.gitea.io/gitea/models/packages/container"
1417
"code.gitea.io/gitea/models/unittest"
1518
user_model "code.gitea.io/gitea/models/user"
1619
api "code.gitea.io/gitea/modules/structs"
20+
packages_service "code.gitea.io/gitea/services/packages"
1721

1822
"github.com/stretchr/testify/assert"
1923
)
@@ -43,7 +47,7 @@ func TestPackageAPI(t *testing.T) {
4347
DecodeJSON(t, resp, &apiPackages)
4448

4549
assert.Len(t, apiPackages, 1)
46-
assert.Equal(t, string(packages.TypeGeneric), apiPackages[0].Type)
50+
assert.Equal(t, string(packages_model.TypeGeneric), apiPackages[0].Type)
4751
assert.Equal(t, packageName, apiPackages[0].Name)
4852
assert.Equal(t, packageVersion, apiPackages[0].Version)
4953
assert.NotNil(t, apiPackages[0].Creator)
@@ -62,7 +66,7 @@ func TestPackageAPI(t *testing.T) {
6266
var p *api.Package
6367
DecodeJSON(t, resp, &p)
6468

65-
assert.Equal(t, string(packages.TypeGeneric), p.Type)
69+
assert.Equal(t, string(packages_model.TypeGeneric), p.Type)
6670
assert.Equal(t, packageName, p.Name)
6771
assert.Equal(t, packageVersion, p.Version)
6872
assert.NotNil(t, p.Creator)
@@ -100,3 +104,26 @@ func TestPackageAPI(t *testing.T) {
100104
MakeRequest(t, req, http.StatusNoContent)
101105
})
102106
}
107+
108+
func TestPackageCleanup(t *testing.T) {
109+
defer prepareTestEnv(t)()
110+
111+
time.Sleep(time.Second)
112+
113+
pbs, err := packages_model.FindExpiredUnreferencedBlobs(db.DefaultContext, time.Duration(0))
114+
assert.NoError(t, err)
115+
assert.NotEmpty(t, pbs)
116+
117+
_, err = packages_model.GetInternalVersionByNameAndVersion(db.DefaultContext, 2, packages_model.TypeContainer, "test", container_model.UploadVersion)
118+
assert.NoError(t, err)
119+
120+
err = packages_service.Cleanup(nil, time.Duration(0))
121+
assert.NoError(t, err)
122+
123+
pbs, err = packages_model.FindExpiredUnreferencedBlobs(db.DefaultContext, time.Duration(0))
124+
assert.NoError(t, err)
125+
assert.Empty(t, pbs)
126+
127+
_, err = packages_model.GetInternalVersionByNameAndVersion(db.DefaultContext, 2, packages_model.TypeContainer, "test", container_model.UploadVersion)
128+
assert.ErrorIs(t, err, packages_model.ErrPackageNotExist)
129+
}

integrations/auth_ldap_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ import (
1616
"code.gitea.io/gitea/models/organization"
1717
"code.gitea.io/gitea/models/unittest"
1818
user_model "code.gitea.io/gitea/models/user"
19+
"code.gitea.io/gitea/modules/translation/i18n"
1920
"code.gitea.io/gitea/services/auth"
2021

2122
"github.com/stretchr/testify/assert"
22-
"github.com/unknwon/i18n"
2323
)
2424

2525
type ldapUser struct {

integrations/branches_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import (
99
"net/url"
1010
"testing"
1111

12+
"code.gitea.io/gitea/modules/translation/i18n"
13+
1214
"github.com/stretchr/testify/assert"
13-
"github.com/unknwon/i18n"
1415
)
1516

1617
func TestViewBranches(t *testing.T) {

integrations/pull_merge_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ import (
2424
"code.gitea.io/gitea/modules/git"
2525
api "code.gitea.io/gitea/modules/structs"
2626
"code.gitea.io/gitea/modules/test"
27+
"code.gitea.io/gitea/modules/translation/i18n"
2728
"code.gitea.io/gitea/services/pull"
2829

2930
"github.com/stretchr/testify/assert"
30-
"github.com/unknwon/i18n"
3131
)
3232

3333
func testPullMerge(t *testing.T, session *TestSession, user, repo, pullnum string, mergeStyle repo_model.MergeStyle) *httptest.ResponseRecorder {

integrations/release_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import (
1414
"code.gitea.io/gitea/models/unittest"
1515
"code.gitea.io/gitea/modules/setting"
1616
"code.gitea.io/gitea/modules/test"
17+
"code.gitea.io/gitea/modules/translation/i18n"
1718

1819
"github.com/PuerkitoBio/goquery"
1920
"github.com/stretchr/testify/assert"
20-
"github.com/unknwon/i18n"
2121
)
2222

2323
func createNewRelease(t *testing.T, session *TestSession, repoURL, tag, title string, preRelease, draft bool) {

integrations/repo_branch_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import (
1313

1414
"code.gitea.io/gitea/modules/setting"
1515
"code.gitea.io/gitea/modules/test"
16+
"code.gitea.io/gitea/modules/translation/i18n"
1617

1718
"github.com/stretchr/testify/assert"
18-
"github.com/unknwon/i18n"
1919
)
2020

2121
func testCreateBranch(t testing.TB, session *TestSession, user, repo, oldRefSubURL, newBranchName string, expectedStatus int) string {

integrations/signin_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111

1212
"code.gitea.io/gitea/models/unittest"
1313
user_model "code.gitea.io/gitea/models/user"
14+
"code.gitea.io/gitea/modules/translation/i18n"
1415

1516
"github.com/stretchr/testify/assert"
16-
"github.com/unknwon/i18n"
1717
)
1818

1919
func testLoginFailed(t *testing.T, username, password, message string) {

integrations/signup_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import (
1313
"code.gitea.io/gitea/models/unittest"
1414
user_model "code.gitea.io/gitea/models/user"
1515
"code.gitea.io/gitea/modules/setting"
16+
"code.gitea.io/gitea/modules/translation/i18n"
1617

1718
"github.com/stretchr/testify/assert"
18-
"github.com/unknwon/i18n"
1919
)
2020

2121
func TestSignup(t *testing.T) {
@@ -68,9 +68,9 @@ func TestSignupEmail(t *testing.T) {
6868
wantStatus int
6969
wantMsg string
7070
}{
71-
{"[email protected]\r\n", http.StatusOK, i18n.Tr("en", "form.email_invalid", nil)},
72-
{"[email protected]\r", http.StatusOK, i18n.Tr("en", "form.email_invalid", nil)},
73-
{"[email protected]\n", http.StatusOK, i18n.Tr("en", "form.email_invalid", nil)},
71+
{"[email protected]\r\n", http.StatusOK, i18n.Tr("en", "form.email_invalid")},
72+
{"[email protected]\r", http.StatusOK, i18n.Tr("en", "form.email_invalid")},
73+
{"[email protected]\n", http.StatusOK, i18n.Tr("en", "form.email_invalid")},
7474
{"[email protected]", http.StatusSeeOther, ""},
7575
}
7676

integrations/user_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111
"code.gitea.io/gitea/models/unittest"
1212
user_model "code.gitea.io/gitea/models/user"
1313
"code.gitea.io/gitea/modules/test"
14+
"code.gitea.io/gitea/modules/translation/i18n"
1415

1516
"github.com/stretchr/testify/assert"
16-
"github.com/unknwon/i18n"
1717
)
1818

1919
func TestViewUser(t *testing.T) {

models/packages/conan/references.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ func findPropertyValues(ctx context.Context, propertyName string, ownerID int64,
6565
in2 := builder.
6666
Select("package_file.id").
6767
From("package_file").
68-
Join("INNER", "package_version", "package_version.id = package_file.version_id").
69-
Join("INNER", "package", "package.id = package_version.package_id").
68+
InnerJoin("package_version", "package_version.id = package_file.version_id").
69+
InnerJoin("package", "package.id = package_version.package_id").
7070
Where(cond)
7171

7272
query := builder.
7373
Select("package_property.value, MAX(package_file.created_unix) AS created_unix").
7474
From("package_property").
75-
Join("INNER", "package_file", "package_file.id = package_property.ref_id").
75+
InnerJoin("package_file", "package_file.id = package_property.ref_id").
7676
Where(builder.Eq{"package_property.name": propertyName}.And(builder.In("package_property.ref_id", in2))).
7777
GroupBy("package_property.value").
7878
OrderBy("created_unix DESC")

models/packages/conan/search.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ func SearchRecipes(ctx context.Context, opts *RecipeSearchOptions) ([]string, er
7474
query := builder.
7575
Select("package.name, package_version.version, package_file.id").
7676
From("package_file").
77-
Join("INNER", "package_version", "package_version.id = package_file.version_id").
78-
Join("INNER", "package", "package.id = package_version.package_id").
77+
InnerJoin("package_version", "package_version.id = package_file.version_id").
78+
InnerJoin("package", "package.id = package_version.package_id").
7979
Where(cond)
8080

8181
results := make([]struct {

models/packages/package.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,15 @@ func GetPackagesByType(ctx context.Context, ownerID int64, packageType Type) ([]
190190
// DeletePackagesIfUnreferenced deletes a package if there are no associated versions
191191
func DeletePackagesIfUnreferenced(ctx context.Context) error {
192192
in := builder.
193-
Select("package_version.package_id").
193+
Select("package.id").
194194
From("package").
195-
Join("LEFT", "package_version", "package_version.package_id = package.id").
195+
LeftJoin("package_version", "package_version.package_id = package.id").
196196
Where(builder.Expr("package_version.id IS NULL"))
197197

198198
_, err := db.GetEngine(ctx).
199-
Where(builder.In("package.id", in)).
199+
// double select workaround for MySQL
200+
// https://stackoverflow.com/questions/4471277/mysql-delete-from-with-subquery-as-condition
201+
Where(builder.In("package.id", builder.Select("id").From(in, "temp"))).
200202
Delete(&Package{})
201203

202204
return err

models/packages/package_blob.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func FindExpiredUnreferencedBlobs(ctx context.Context, olderThan time.Duration)
6767
pbs := make([]*PackageBlob, 0, 10)
6868
return pbs, db.GetEngine(ctx).
6969
Table("package_blob").
70-
Join("LEFT OUTER", "package_file", "package_file.blob_id = package_blob.id").
70+
Join("LEFT", "package_file", "package_file.blob_id = package_blob.id").
7171
Where("package_file.id IS NULL AND package_blob.created_unix < ?", time.Now().Add(-olderThan).Unix()).
7272
Find(&pbs)
7373
}

models/packages/package_file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (opts *PackageFileSearchOptions) toConds() builder.Cond {
147147
in := builder.
148148
Select("package_version.id").
149149
From("package_version").
150-
Join("INNER", "package", "package.id = package_version.package_id").
150+
InnerJoin("package", "package.id = package_version.package_id").
151151
Where(versionCond)
152152

153153
cond = cond.And(builder.In("package_file.version_id", in))

0 commit comments

Comments
 (0)