@@ -3,7 +3,7 @@ package main
33import (
44 "errors"
55 "fmt"
6- "math/rand"
6+ "math/rand/v2 "
77 "os"
88 "path/filepath"
99 aptly "raptly/pkg/rest-aptly"
@@ -167,6 +167,11 @@ func (c *RepoRemoveCmd) Run(ctx *Context) error {
167167 return nil
168168}
169169
170+ const ExtDsc = ".dsc"
171+ const ExtDeb = ".deb"
172+ const ExtUdeb = ".ubed"
173+ const ExtChanged = ".changes"
174+
170175type RepoAddCmd struct {
171176 ForceReplace bool `kong:"name='force-replace'"`
172177 // RemoveFiles bool `kong:"name='remove-files'"`
@@ -190,7 +195,7 @@ func (c *RepoAddCmd) Run(ctx *Context) error {
190195 extension := filepath .Ext (path )
191196 if isDebianFile (extension ) {
192197 filesToUpload = append (filesToUpload , path )
193- if extension == ".dsc" {
198+ if extension == ExtDsc {
194199 referenced , err := getFilesFromDsc (path )
195200 if err != nil {
196201 return err
@@ -211,7 +216,7 @@ func (c *RepoAddCmd) Run(ctx *Context) error {
211216 extension := filepath .Ext (c .Path )
212217 if isDebianFile (extension ) {
213218 filesToUpload = append (filesToUpload , c .Path )
214- if extension == ".dsc" {
219+ if extension == ExtDsc {
215220 referenced , err := getFilesFromDsc (c .Path )
216221 if err != nil {
217222 return err
@@ -239,23 +244,21 @@ func (c *RepoAddCmd) Run(ctx *Context) error {
239244 return nil
240245}
241246
242- var letters = []rune ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" )
243-
244247func randSeq (n int ) string {
248+ var letters = []rune ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" )
245249 b := make ([]rune , n )
246250 for i := range b {
247- b [i ] = letters [rand .Intn (len (letters ))]
251+ b [i ] = letters [rand .IntN (len (letters ))]
248252 }
249253 return string (b )
250254}
251255
252256func isDebianFile (extension string ) bool {
253- return extension == ".deb" || extension == ".udeb" || extension == ".dsc"
257+ return extension == ExtDeb || extension == ExtUdeb || extension == ExtDsc
254258}
255259
256260func checkFileExists (filePath string ) bool {
257261 _ , error := os .Stat (filePath )
258- //return !os.IsNotExist(err)
259262 return ! errors .Is (error , os .ErrNotExist )
260263}
261264
@@ -299,7 +302,7 @@ func (c *RepoIncludeCmd) Run(ctx *Context) error {
299302 err := filepath .Walk (c .Path , func (path string , info os.FileInfo , err error ) error {
300303 if ! info .IsDir () {
301304 extension := filepath .Ext (path )
302- if extension == ".changes" {
305+ if extension == ExtChanged {
303306 filesToUpload = append (filesToUpload , path )
304307 referenced , err := getFilesFromChanges (path )
305308 if err != nil {
0 commit comments