mirror of
https://github.com/harness/drone.git
synced 2025-05-10 07:30:33 +08:00
fix reposGraveyard dir path (#939)
This commit is contained in:
parent
a4d47e12b2
commit
bd495845ae
@ -183,7 +183,7 @@ func (s *Service) Merge(ctx context.Context, params *MergeParams) (MergeOutput,
|
||||
log.Debug().Msg("prepare sparse-checkout")
|
||||
|
||||
infoPath := filepath.Join(tmpRepo.Path, ".git", "info")
|
||||
if err = os.MkdirAll(infoPath, 0o700); err != nil {
|
||||
if err = os.MkdirAll(infoPath, fileMode700); err != nil {
|
||||
return MergeOutput{}, fmt.Errorf("unable to create .git/info in tmpRepo.Path: %w", err)
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,8 @@ const (
|
||||
gitReferenceNamePrefixTag = "refs/tags/"
|
||||
|
||||
gitHooksDir = "hooks"
|
||||
|
||||
fileMode700 = 0o700
|
||||
)
|
||||
|
||||
var (
|
||||
@ -223,6 +225,12 @@ func (s *Service) DeleteRepositoryBestEffort(ctx context.Context, repoUID string
|
||||
repoPath := getFullPathForRepo(s.reposRoot, repoUID)
|
||||
tempPath := path.Join(s.reposGraveyard, repoUID)
|
||||
|
||||
// delete should not fail if repoGraveyard dir does not exist
|
||||
if _, err := os.Stat(s.reposGraveyard); os.IsNotExist(err) {
|
||||
if errdir := os.MkdirAll(s.reposGraveyard, fileMode700); errdir != nil {
|
||||
return fmt.Errorf("clean up dir '%s' doesn't exist and can't be created: %w", s.reposGraveyard, errdir)
|
||||
}
|
||||
}
|
||||
// move current dir to a temp dir (prevent partial deletion)
|
||||
if err := os.Rename(repoPath, tempPath); err != nil {
|
||||
return fmt.Errorf("couldn't move dir %s to %s : %w", repoPath, tempPath, err)
|
||||
|
@ -45,16 +45,16 @@ func New(
|
||||
// Create repos folder
|
||||
reposRoot := filepath.Join(config.Root, repoSubdirName)
|
||||
if _, err := os.Stat(reposRoot); errors.Is(err, os.ErrNotExist) {
|
||||
if err = os.MkdirAll(reposRoot, 0o700); err != nil {
|
||||
if err = os.MkdirAll(reposRoot, fileMode700); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// create a temp dir for deleted repositories
|
||||
// this dir should get cleaned up peridocally if it's not empty
|
||||
reposGraveyard := filepath.Join(reposRoot, ReposGraveyardSubdirName)
|
||||
reposGraveyard := filepath.Join(config.Root, ReposGraveyardSubdirName)
|
||||
if _, errdir := os.Stat(reposGraveyard); os.IsNotExist(errdir) {
|
||||
if errdir = os.MkdirAll(reposGraveyard, 0o700); errdir != nil {
|
||||
if errdir = os.MkdirAll(reposGraveyard, fileMode700); errdir != nil {
|
||||
return nil, errdir
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user