From cc0d70c3d621d9566fc4bf32a52fa6f6970d57f0 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 6 Oct 2022 13:08:28 +0300 Subject: [PATCH] lib/backup/azremote: remove unused methods after the 262ce77e2d8fba0d4c7187654b7fbd255e7e9e3d --- lib/backup/azremote/azblob.go | 77 ----------------------------------- 1 file changed, 77 deletions(-) diff --git a/lib/backup/azremote/azblob.go b/lib/backup/azremote/azblob.go index 1d3260e00..1892f121b 100644 --- a/lib/backup/azremote/azblob.go +++ b/lib/backup/azremote/azblob.go @@ -6,7 +6,6 @@ import ( "fmt" "io" "os" - "path/filepath" "strings" "time" @@ -327,79 +326,3 @@ func (fs *FS) HasFile(filePath string) (bool, error) { return true, nil } - -// ListDirs returns list of subdirectories in given directory -func (fs *FS) ListDirs(subpath string) ([]string, error) { - path := strings.TrimPrefix(filepath.Join(fs.Dir, subpath), "/") - if path != "" && !strings.HasSuffix(path, "/") { - path += "/" - } - - var dirs []string - - const dirsDelimiter = "/" - pager := fs.client.ListBlobsHierarchy(dirsDelimiter, &azblob.ContainerListBlobsHierarchyOptions{ - Prefix: &fs.Container, - }) - ctx := context.Background() - for pager.NextPage(ctx) { - resp := pager.PageResponse() - - const dirsDelimiter = "/" - - for _, v := range resp.Segment.BlobPrefixes { - dir := *v.Name - if !strings.HasPrefix(dir, path) { - return nil, fmt.Errorf("unexpected prefix for AZBlob key %q; want %q", dir, dir) - } - dir = strings.TrimPrefix(dir, path) - if fscommon.IgnorePath(dir) || !strings.Contains(dir, dirsDelimiter) { - continue - } - dirs = append(dirs, strings.TrimSuffix(dir, dirsDelimiter)) - } - } - - return dirs, nil -} - -// DeleteFiles deletes files at fs. -// -// The function does nothing if the files don't exist. -func (fs *FS) DeleteFiles(filePaths []string) error { - if len(filePaths) == 0 { - return nil - } - for _, filePath := range filePaths { - path := filePath - if fs.Dir != "/" { - path = filepath.Join(fs.Dir + path) - } - - ctx := context.Background() - - opts := &azblob.ContainerListBlobsFlatOptions{ - Prefix: &path, - } - - pager := fs.client.ListBlobsFlat(opts) - for pager.NextPage(ctx) { - resp := pager.PageResponse() - - for _, v := range resp.Segment.BlobItems { - file := *v.Name - - bc, err := fs.clientForPath(file) - if err != nil { - return err - } - - _, err = bc.Delete(ctx, &azblob.BlobDeleteOptions{}) - if err != nil { - return fmt.Errorf("cannot delete %q at %s (remote dir %q): %w", file, fs, fs.Dir, err) - } - } - } - } - return nil -}