@ -8,6 +8,7 @@ import (
"context"
"context"
"fmt"
"fmt"
"os"
"os"
"path"
"path/filepath"
"path/filepath"
"strings"
"strings"
@ -220,21 +221,21 @@ func DeleteUnadoptedRepository(doer, u *user_model.User, repoName string) error
return util . RemoveAll ( repoPath )
return util . RemoveAll ( repoPath )
}
}
type unadoptedRr epositories struct {
type unadoptedRepositories struct {
repositories [ ] string
repositories [ ] string
index int
index int
start int
start int
end int
end int
}
}
func ( unadopted * unadoptedRr epositories ) add ( repository string ) {
func ( unadopted * unadoptedRepositories ) add ( repository string ) {
if unadopted . index >= unadopted . start && unadopted . index < unadopted . end {
if unadopted . index >= unadopted . start && unadopted . index < unadopted . end {
unadopted . repositories = append ( unadopted . repositories , repository )
unadopted . repositories = append ( unadopted . repositories , repository )
}
}
unadopted . index ++
unadopted . index ++
}
}
func checkUnadoptedRepositories ( userName string , repoNamesToCheck [ ] string , unadopted * unadoptedRr epositories ) error {
func checkUnadoptedRepositories ( userName string , repoNamesToCheck [ ] string , unadopted * unadoptedRepositories ) error {
if len ( repoNamesToCheck ) == 0 {
if len ( repoNamesToCheck ) == 0 {
return nil
return nil
}
}
@ -266,7 +267,7 @@ func checkUnadoptedRepositories(userName string, repoNamesToCheck []string, unad
}
}
for _ , repoName := range repoNamesToCheck {
for _ , repoName := range repoNamesToCheck {
if _ , ok := repoNames [ repoName ] ; ! ok {
if _ , ok := repoNames [ repoName ] ; ! ok {
unadopted . add ( file path. Join ( userName , repoName ) )
unadopted . add ( path . Join ( userName , repoName ) ) // These are not used as filepaths - but as reponames - therefore use path.Join not filepath.Join
}
}
}
}
return nil
return nil
@ -294,7 +295,7 @@ func ListUnadoptedRepositories(query string, opts *db.ListOptions) ([]string, in
var repoNamesToCheck [ ] string
var repoNamesToCheck [ ] string
start := ( opts . Page - 1 ) * opts . PageSize
start := ( opts . Page - 1 ) * opts . PageSize
unadopted := & unadoptedRr epositories {
unadopted := & unadoptedRepositories {
repositories : make ( [ ] string , 0 , opts . PageSize ) ,
repositories : make ( [ ] string , 0 , opts . PageSize ) ,
start : start ,
start : start ,
end : start + opts . PageSize ,
end : start + opts . PageSize ,