diff --git a/daemon/volumes.go b/daemon/volumes.go index e8f3327de5..36cf5c4be6 100644 --- a/daemon/volumes.go +++ b/daemon/volumes.go @@ -8,7 +8,6 @@ import ( "path/filepath" "strings" - "github.com/Sirupsen/logrus" "github.com/docker/docker/pkg/chrootarchive" "github.com/docker/docker/runconfig" "github.com/docker/docker/volume" @@ -291,37 +290,6 @@ func (daemon *Daemon) verifyVolumesInfo(container *Container) error { return container.ToDisk() } -// 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 -} - func createVolume(name, driverName string) (volume.Volume, error) { vd, err := getVolumeDriver(driverName) if err != nil { 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 +} diff --git a/daemon/volumes_windows.go b/daemon/volumes_windows.go index c37ca220d7..aefdc49752 100644 --- a/daemon/volumes_windows.go +++ b/daemon/volumes_windows.go @@ -12,3 +12,7 @@ func copyOwnership(source, destination string) error { func (container *Container) setupMounts() ([]execdriver.Mount, error) { return nil, nil } + +func (daemon *Daemon) migrateVolume(id, vfs string) error { + return nil +}