Remove automatic repository subdirectories
This commit is contained in:
@@ -22,7 +22,6 @@ type MountManager struct {
|
||||
type MountedRepository struct {
|
||||
Repository model.Repository
|
||||
Mounted bool
|
||||
MountPoint string
|
||||
CredentialFile string
|
||||
}
|
||||
|
||||
@@ -33,12 +32,7 @@ func (m *MountManager) Prepare(ctx context.Context, repo model.Repository) (Moun
|
||||
}
|
||||
if repo.Mount == nil || !repo.Mount.Managed {
|
||||
if _, err := os.Stat(repo.Location); err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return result, fmt.Errorf("connectivity: external mount unavailable: %w", err)
|
||||
}
|
||||
if _, parentErr := os.Stat(filepath.Dir(repo.Location)); parentErr != nil {
|
||||
return result, fmt.Errorf("connectivity: external mount unavailable: %w", parentErr)
|
||||
}
|
||||
return result, fmt.Errorf("connectivity: external mount unavailable: %w", err)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
@@ -46,11 +40,6 @@ func (m *MountManager) Prepare(ctx context.Context, repo model.Repository) (Moun
|
||||
if !strings.HasPrefix(point, "/mnt/remotes/") && !strings.HasPrefix(point, "/mnt/disks/") {
|
||||
return result, errors.New("validation: managed mountPoint must be below /mnt/remotes or /mnt/disks")
|
||||
}
|
||||
repositoryPath := filepath.Clean(repo.Location)
|
||||
relative, err := filepath.Rel(point, repositoryPath)
|
||||
if err != nil || relative == ".." || strings.HasPrefix(relative, ".."+string(filepath.Separator)) {
|
||||
return result, errors.New("validation: managed repository location must be inside its mountPoint")
|
||||
}
|
||||
if err := os.MkdirAll(point, 0700); err != nil {
|
||||
return result, err
|
||||
}
|
||||
@@ -97,7 +86,7 @@ func (m *MountManager) Prepare(ctx context.Context, repo model.Repository) (Moun
|
||||
return result, fmt.Errorf("connectivity: mount repository: %w", err)
|
||||
}
|
||||
result.Mounted = true
|
||||
result.MountPoint = point
|
||||
result.Repository.Location = point
|
||||
return result, nil
|
||||
}
|
||||
|
||||
@@ -108,5 +97,5 @@ func (m *MountManager) Cleanup(ctx context.Context, mounted MountedRepository) e
|
||||
if !mounted.Mounted {
|
||||
return nil
|
||||
}
|
||||
return exec.CommandContext(ctx, "umount", mounted.MountPoint).Run()
|
||||
return exec.CommandContext(ctx, "umount", mounted.Repository.Location).Run()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user