本文整理汇总了Golang中github.com/snapcore/snapd/snap.PlaceInfo.MountDir方法的典型用法代码示例。如果您正苦于以下问题:Golang PlaceInfo.MountDir方法的具体用法?Golang PlaceInfo.MountDir怎么用?Golang PlaceInfo.MountDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/snapcore/snapd/snap.PlaceInfo
的用法示例。
在下文中一共展示了PlaceInfo.MountDir方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RemoveSnapFiles
// RemoveSnapFiles removes the snap files from the disk after unmounting the snap.
func (b Backend) RemoveSnapFiles(s snap.PlaceInfo, typ snap.Type, meter progress.Meter) error {
mountDir := s.MountDir()
// this also ensures that the mount unit stops
if err := removeMountUnit(mountDir, meter); err != nil {
return err
}
if err := os.RemoveAll(mountDir); err != nil {
return err
}
// try to remove parent dir, failure is ok, means some other
// revisions are still in there
os.Remove(filepath.Dir(mountDir))
// snapPath may either be a file or a (broken) symlink to a dir
snapPath := s.MountFile()
if _, err := os.Lstat(snapPath); err == nil {
// remove the kernel assets (if any)
if typ == snap.TypeKernel {
if err := boot.RemoveKernelAssets(s); err != nil {
return err
}
}
// remove the snap
if err := os.RemoveAll(snapPath); err != nil {
return err
}
}
return nil
}
示例2: removeCurrentSymlinks
func removeCurrentSymlinks(info snap.PlaceInfo) error {
var err1, err2 error
// the snap "current" symlink
currentActiveSymlink := filepath.Join(info.MountDir(), "..", "current")
err1 = os.Remove(currentActiveSymlink)
if err1 != nil && !os.IsNotExist(err1) {
logger.Noticef("Cannot remove %q: %v", currentActiveSymlink, err1)
} else {
err1 = nil
}
// the data "current" symlink
currentDataSymlink := filepath.Join(info.DataDir(), "..", "current")
err2 = os.Remove(currentDataSymlink)
if err2 != nil && !os.IsNotExist(err2) {
logger.Noticef("Cannot remove %q: %v", currentDataSymlink, err2)
} else {
err2 = nil
}
if err1 != nil && err2 != nil {
return fmt.Errorf("cannot remove snap current symlink: %v and %v", err1, err2)
} else if err1 != nil {
return fmt.Errorf("cannot remove snap current symlink: %v", err1)
} else if err2 != nil {
return fmt.Errorf("cannot remove snap current symlink: %v", err2)
}
return nil
}
示例3: RemoveSnapFiles
func (f *fakeSnappyBackend) RemoveSnapFiles(s snap.PlaceInfo, typ snap.Type, meter progress.Meter) error {
meter.Notify("remove-snap-files")
f.ops = append(f.ops, fakeOp{
op: "remove-snap-files",
name: s.MountDir(),
stype: typ,
})
return nil
}
示例4: UndoSetupSnap
func (f *fakeSnappyBackend) UndoSetupSnap(s snap.PlaceInfo, typ snap.Type, p progress.Meter) error {
p.Notify("setup-snap")
f.ops = append(f.ops, fakeOp{
op: "undo-setup-snap",
name: s.MountDir(),
stype: typ,
})
return nil
}