Skip to content

Commit

Permalink
o/snapstate: update doc comments on Download and DownloadComponents
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewphelpsj committed Dec 16, 2024
1 parent 5bb6a01 commit caed45c
Showing 1 changed file with 29 additions and 21 deletions.
50 changes: 29 additions & 21 deletions overlord/snapstate/snapstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -1536,10 +1536,12 @@ func InstallPathWithDeviceContext(st *state.State, si *snap.SideInfo, path, name
}

// Download returns a set of tasks for downloading a snap and components into
// the given blobDirectory. If blobDirectory is empty, then dirs.SnapBlobDir is
// used. The snap.Info for the snap that is downloaded is also returned. The
// tasks that are returned will also download and validate the snap's and
// components' assertions. Prerequisites for the snap are not downloaded.
// the given directory. The snap.Info for the snap that is downloaded is also
// returned. The tasks that are returned also download and validate the snap's
// and components' assertions. Prerequisites for the snap are not downloaded.
//
// TODO: this function will soon return an error if downloadDir ==
// dirs.SnapBlobDir.
func Download(
ctx context.Context,
st *state.State,
Expand All @@ -1553,6 +1555,29 @@ func Download(
return downloadTasks(ctx, st, name, components, downloadDir, skipSnapDownload, revOpts, opts)
}

// DownloadComponents returns a set of tasks for downloading the given snap
// components into the given directory. The tasks that are returned will also
// download and validate the components' assertions.
//
// TODO: this function will soon return an error if downloadDir ==
// dirs.SnapBlobDir.
func DownloadComponents(
ctx context.Context,
st *state.State,
name string,
components []string,
downloadDir string,
revOpts RevisionOptions,
opts Options,
) (*state.TaskSet, error) {
const skipSnapDownload = true
ts, _, err := downloadTasks(ctx, st, name, components, downloadDir, skipSnapDownload, revOpts, opts)
if err != nil {
return nil, err
}
return ts, nil
}

func downloadTasks(
ctx context.Context,
st *state.State,
Expand Down Expand Up @@ -1701,23 +1726,6 @@ func downloadTasks(
return ts, info, nil
}

func DownloadComponents(
ctx context.Context,
st *state.State,
name string,
components []string,
dir string,
revOpts RevisionOptions,
opts Options,
) (*state.TaskSet, error) {
const skipSnapDownload = true
ts, _, err := downloadTasks(ctx, st, name, components, dir, skipSnapDownload, revOpts, opts)
if err != nil {
return nil, err
}
return ts, nil
}

func validatedInfoFromPathAndSideInfo(instanceName string, path string, si *snap.SideInfo) (*snap.Info, error) {
var info *snap.Info
info, cont, err := backend.OpenSnapFile(path, si)
Expand Down

0 comments on commit caed45c

Please sign in to comment.