Use stow api correctly to find our function storage container on restarts.
This commit is contained in:
committed by
Soam Vasani
parent
42819ba362
commit
a720377f3c
@@ -24,7 +24,6 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/gorilla/handlers"
|
"github.com/gorilla/handlers"
|
||||||
@@ -203,8 +202,19 @@ func MakeStorageService(sc *storageConfig) (*StorageService, error) {
|
|||||||
|
|
||||||
con, err := loc.CreateContainer(sc.containerName)
|
con, err := loc.CreateContainer(sc.containerName)
|
||||||
if os.IsExist(err) {
|
if os.IsExist(err) {
|
||||||
id := filepath.Join(sc.localPath, sc.containerName)
|
var cons []stow.Container
|
||||||
con, err = loc.Container(id)
|
var cursor string
|
||||||
|
|
||||||
|
// use location.Containers to find containers that match the prefix (container name)
|
||||||
|
cons, cursor, err = loc.Containers(sc.containerName, stow.CursorStart, 1)
|
||||||
|
if err == nil {
|
||||||
|
if !stow.IsCursorEnd(cursor) {
|
||||||
|
// Should only have one storage container
|
||||||
|
err = errors.New("Found more than one matched storage containers")
|
||||||
|
} else {
|
||||||
|
con = cons[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error initializing storage: %v", err)
|
log.Printf("Error initializing storage: %v", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user