summaryrefslogtreecommitdiff
path: root/daemon/volumes_linux.go
diff options
context:
space:
mode:
authorJohn Howard <jhoward@microsoft.com>2015-06-08 13:45:28 -0700
committerJohn Howard <jhoward@microsoft.com>2015-06-08 13:47:09 -0700
commit71eadd4176a968399671e5cb4c8de52c40992b01 (patch)
treecdf06497eafcae96c627b967b53ae8ab7d1f554b /daemon/volumes_linux.go
parentb099eb796a54276ea6585d9647b274d296a83aed (diff)
downloaddocker-71eadd4176a968399671e5cb4c8de52c40992b01.tar.gz
Windows: Fix PR13278 compile break
Signed-off-by: John Howard <jhoward@microsoft.com>
Diffstat (limited to 'daemon/volumes_linux.go')
-rw-r--r--daemon/volumes_linux.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/daemon/volumes_linux.go b/daemon/volumes_linux.go
index 8eea5e067f..e522001501 100644
--- a/daemon/volumes_linux.go
+++ b/daemon/volumes_linux.go
@@ -8,6 +8,7 @@ import (
"sort"
"strings"
+ "github.com/Sirupsen/logrus"
"github.com/docker/docker/daemon/execdriver"
"github.com/docker/docker/pkg/system"
)
@@ -68,3 +69,34 @@ func (m mounts) Swap(i, j int) {
func (m mounts) parts(i int) int {
return len(strings.Split(filepath.Clean(m[i].Destination), string(os.PathSeparator)))
}
+
+// migrateVolume moves the contents of a volume created pre Docker 1.7
+// to the location expected by the local driver. Steps:
+// 1. Save old directory that includes old volume's config json file.
+// 2. Move virtual directory with content to where the local driver expects it to be.
+// 3. Remove the backup of the old volume config.
+func (daemon *Daemon) migrateVolume(id, vfs string) error {
+ volumeInfo := filepath.Join(daemon.root, defaultVolumesPathName, id)
+ backup := filepath.Join(daemon.root, defaultVolumesPathName, id+".back")
+
+ var err error
+ if err = os.Rename(volumeInfo, backup); err != nil {
+ return err
+ }
+ defer func() {
+ // Put old configuration back in place in case one of the next steps fails.
+ if err != nil {
+ os.Rename(backup, volumeInfo)
+ }
+ }()
+
+ if err = os.Rename(vfs, volumeInfo); err != nil {
+ return err
+ }
+
+ if err = os.RemoveAll(backup); err != nil {
+ logrus.Errorf("Unable to remove volume info backup directory %s: %v", backup, err)
+ }
+
+ return nil
+}