|
@@ -277,6 +277,18 @@ func scanPriorDrivers(root string) map[string]bool {
|
|
return driversMap
|
|
return driversMap
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// IsInitialized checks if the driver's home-directory exists and is non-empty.
|
|
|
|
+func IsInitialized(driverHome string) bool {
|
|
|
|
+ _, err := os.Stat(driverHome)
|
|
|
|
+ if os.IsNotExist(err) {
|
|
|
|
+ return false
|
|
|
|
+ }
|
|
|
|
+ if err != nil {
|
|
|
|
+ logrus.Warnf("graphdriver.IsInitialized: stat failed: %v", err)
|
|
|
|
+ }
|
|
|
|
+ return !isEmptyDir(driverHome)
|
|
|
|
+}
|
|
|
|
+
|
|
// isEmptyDir checks if a directory is empty. It is used to check if prior
|
|
// isEmptyDir checks if a directory is empty. It is used to check if prior
|
|
// storage-driver directories exist. If an error occurs, it also assumes the
|
|
// storage-driver directories exist. If an error occurs, it also assumes the
|
|
// directory is not empty (which preserves the behavior _before_ this check
|
|
// directory is not empty (which preserves the behavior _before_ this check
|