@@ -2,12 +2,12 @@ package maven
22
33import (
44 "context"
5- "encoding/json"
65 "errors"
76 "fmt"
87 "strings"
98
109 "code.gitea.io/gitea/models/packages"
10+ "code.gitea.io/gitea/modules/json"
1111 "code.gitea.io/gitea/modules/log"
1212 "code.gitea.io/gitea/modules/packages/maven"
1313 "code.gitea.io/gitea/modules/setting"
@@ -38,21 +38,21 @@ func CleanupSnapshotVersions(ctx context.Context) error {
3838 continue
3939 }
4040
41- var artifactId , groupId string
41+ var artifactID , groupID string
4242 if version .MetadataJSON != "" {
43- var metadata map [string ]interface {}
43+ var metadata map [string ]any
4444 if err := json .Unmarshal ([]byte (version .MetadataJSON ), & metadata ); err != nil {
4545 log .Warn ("Maven Cleanup: error during cleanup: failed to unmarshal metadataJSON for package version ID: %d: %w" , version .ID , err )
4646 } else {
47- artifactId , _ = metadata ["artifact_id" ].(string )
48- groupId , _ = metadata ["group_id" ].(string )
49- log .Trace ("Maven Cleanup: processing package version with ID: %s, Group ID: %s, Artifact ID: %s, Version: %s" , version .ID , groupId , artifactId , version .Version )
47+ artifactID , _ = metadata ["artifact_id" ].(string )
48+ groupID , _ = metadata ["group_id" ].(string )
49+ log .Debug ("Maven Cleanup: processing package version with ID: %s, Group ID: %s, Artifact ID: %s, Version: %s" , version .ID , groupID , artifactID , version .Version )
5050 }
5151 }
5252
5353 if err := cleanSnapshotFiles (ctx , version .ID , retainBuilds , debugSession ); err != nil {
5454 formattedErr := fmt .Errorf ("version '%s' (ID: %d, Group ID: %s, Artifact ID: %s): %w" ,
55- version .Version , version .ID , groupId , artifactId , err )
55+ version .Version , version .ID , groupID , artifactID , err )
5656
5757 if errors .Is (err , packages .ErrMetadataFile ) {
5858 metadataErrors = append (metadataErrors , formattedErr )
@@ -70,10 +70,10 @@ func CleanupSnapshotVersions(ctx context.Context) error {
7070 for _ , err := range errs {
7171 log .Error ("Maven Cleanup: error during cleanup: %v" , err )
7272 }
73- return fmt .Errorf ("maven Cleanup : completed with errors: %v" , errs )
73+ return fmt .Errorf ("maven cleanup : completed with errors: %v" , errs )
7474 }
7575
76- log .Trace ("Completed Maven Cleanup" )
76+ log .Debug ("Completed Maven Cleanup" )
7777 return nil
7878}
7979
@@ -82,7 +82,7 @@ func isSnapshotVersion(version string) bool {
8282}
8383
8484func cleanSnapshotFiles (ctx context.Context , versionID int64 , retainBuilds int , debugSession bool ) error {
85- log .Trace ("Maven Cleanup: starting cleanSnapshotFiles for versionID: %d with retainBuilds: %d, debugSession: %t" , versionID , retainBuilds , debugSession )
85+ log .Debug ("Maven Cleanup: starting cleanSnapshotFiles for versionID: %d with retainBuilds: %d, debugSession: %t" , versionID , retainBuilds , debugSession )
8686
8787 metadataFile , err := packages .GetFileForVersionByName (ctx , versionID , "maven-metadata.xml" , packages .EmptyFileKey )
8888 if err != nil {
@@ -96,7 +96,7 @@ func cleanSnapshotFiles(ctx context.Context, versionID int64, retainBuilds int,
9696
9797 thresholdBuildNumber := maxBuildNumber - retainBuilds
9898 if thresholdBuildNumber <= 0 {
99- log .Trace ("Maven Cleanup: no files to clean up, as the threshold build number is less than or equal to zero for versionID %d" , versionID )
99+ log .Debug ("Maven Cleanup: no files to clean up, as the threshold build number is less than or equal to zero for versionID %d" , versionID )
100100 return nil
101101 }
102102
@@ -121,7 +121,7 @@ func cleanSnapshotFiles(ctx context.Context, versionID int64, retainBuilds int,
121121 }
122122
123123 for _ , file := range filesToRemove {
124- log .Trace ("Maven Cleanup: removing file '%s' below threshold %d" , file .Name , thresholdBuildNumber )
124+ log .Debug ("Maven Cleanup: removing file '%s' below threshold %d" , file .Name , thresholdBuildNumber )
125125 if err := packages_service .DeletePackageFile (ctx , file ); err != nil {
126126 return fmt .Errorf ("cleanSnapshotFiles: failed to delete file '%s': %w" , file .Name , err )
127127 }
0 commit comments