The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/2060
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 #2059 Signed-off-by: Tycho Andersen <tycho.ander...@canonical.com>
From c11058ef81ee109cb82a6ea0cc70a5b32949bea4 Mon Sep 17 00:00:00 2001 From: Tycho Andersen <tycho.ander...@canonical.com> Date: Tue, 31 May 2016 09:55:40 -0600 Subject: [PATCH] GET of a nonexistent file 404s Closes #2059 Signed-off-by: Tycho Andersen <tycho.ander...@canonical.com> --- lxd/container_file.go | 2 +- lxd/container_lxc.go | 3 +++ test/suites/filemanip.sh | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lxd/container_file.go b/lxd/container_file.go index 06590a5..7ac2085 100644 --- a/lxd/container_file.go +++ b/lxd/container_file.go @@ -52,7 +52,7 @@ func containerFileGet(c container, path string, r *http.Request) Response { // Pul the file from the container uid, gid, mode, err := c.FilePull(path, temp.Name()) if err != nil { - return InternalError(err) + return SmartError(err) } headers := map[string]string{ diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go index 6aa3510..e07d974 100644 --- a/lxd/container_lxc.go +++ b/lxd/container_lxc.go @@ -2886,6 +2886,9 @@ func (c *containerLXC) FilePull(srcpath string, dstpath string) (int, int, os.Fi // Extract errors if strings.HasPrefix(line, "error: ") { + if strings.HasSuffix(line, "No such file or directory") { + return -1, -1, 0, os.ErrNotExist + } return -1, -1, 0, fmt.Errorf(strings.TrimPrefix(line, "error: ")) } diff --git a/test/suites/filemanip.sh b/test/suites/filemanip.sh index f4b7b05..07ca148 100644 --- a/test/suites/filemanip.sh +++ b/test/suites/filemanip.sh @@ -2,6 +2,7 @@ test_filemanip() { ensure_import_testimage + ensure_has_localhost_remote "${LXD_ADDR}" lxc launch testimage filemanip lxc exec filemanip -- ln -s /tmp/ /tmp/outside @@ -10,5 +11,9 @@ test_filemanip() { [ ! -f /tmp/main.sh ] lxc exec filemanip -- ls /tmp/main.sh + # missing files should return 404 + err=$(my_curl -o /dev/null -w "%{http_code}" -X GET "https://${LXD_ADDR}/1.0/containers/filemanip/files?path=/tmp/foo") + [ "${err}" -eq "404" ] + lxc delete filemanip -f }
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel