The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/3199

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Closes #3198.

Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
From ebc81ed050238547b63da69c7ad4ba573bc7830a Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brau...@ubuntu.com>
Date: Thu, 20 Apr 2017 17:47:00 +0200
Subject: [PATCH] lxd import: handle non-existing snapshots path

Closes #3198.

Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
---
 lxd/api_internal.go | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/lxd/api_internal.go b/lxd/api_internal.go
index f9627e9..2298d84 100644
--- a/lxd/api_internal.go
+++ b/lxd/api_internal.go
@@ -249,19 +249,22 @@ func internalImport(d *Daemon, r *http.Request) Response {
 
        // Detect discrepancy between snapshots recorded in "backup.yaml" and
        // those actually existing on disk.
+       snapshotNames := []string{}
        snapshotsPath := getSnapshotMountPoint(containerPoolName, req.Name)
        snapshotsDir, err := os.Open(snapshotsPath)
        if err != nil {
-               return InternalError(err)
-       }
-
-       // Get a list of all snapshots that exist on disk.
-       snapshotNames, err := snapshotsDir.Readdirnames(-1)
-       if err != nil {
+               if !os.IsNotExist(err) {
+                       return InternalError(err)
+               }
+       } else {
+               // Get a list of all snapshots that exist on disk.
+               snapshotNames, err = snapshotsDir.Readdirnames(-1)
+               if err != nil {
+                       snapshotsDir.Close()
+                       return InternalError(err)
+               }
                snapshotsDir.Close()
-               return InternalError(err)
        }
-       snapshotsDir.Close()
 
        onDiskSnapshots := map[string]*api.ContainerSnapshot{}
        for _, snapName := range snapshotNames {
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to