diff --git a/pkg/serverinit/genconfig.go b/pkg/serverinit/genconfig.go index 0c2dbcbcc..bc2b3288c 100644 --- a/pkg/serverinit/genconfig.go +++ b/pkg/serverinit/genconfig.go @@ -55,7 +55,8 @@ func addPublishedConfig(prefixes jsonconfig.Obj, sourceRoot string) ([]interface{}, error) { pubPrefixes := []interface{}{} for k, v := range published { - rootName := strings.Replace(k, "/", "", -1) + "Root" + name := strings.Replace(k, "/", "", -1) + rootName := name + "Root" if !v.Root.Valid() { return nil, fmt.Errorf("Invalid or missing \"rootPermanode\" key in configuration for %s.", k) } @@ -86,7 +87,7 @@ func addPublishedConfig(prefixes jsonconfig.Obj, thumbsCacheDir := filepath.Join(tempDir(), "camli-cache") handlerArgs["scaledImage"] = map[string]interface{}{ "type": "kv", - "file": filepath.Join(thumbsCacheDir, "thumbnails.kv"), + "file": filepath.Join(thumbsCacheDir, name+"-thumbnails.kv"), } if err := os.MkdirAll(thumbsCacheDir, 0700); err != nil { return nil, fmt.Errorf("Could not create cache dir %s: %v", thumbsCacheDir, err) diff --git a/pkg/serverinit/testdata/multipublish-want.json b/pkg/serverinit/testdata/multipublish-want.json new file mode 100644 index 000000000..b05724f41 --- /dev/null +++ b/pkg/serverinit/testdata/multipublish-want.json @@ -0,0 +1,159 @@ +{ + "auth": "userpass:camlistore:pass3179", + "https": false, + "listen": "localhost:3179", + "prefixes": { + "/": { + "handler": "root", + "handlerArgs": { + "blobRoot": "/bs-and-maybe-also-index/", + "ownerName": "Alice", + "searchRoot": "/my-search/", + "statusRoot": "/status/", + "stealth": false + } + }, + "/bs-and-index/": { + "handler": "storage-replica", + "handlerArgs": { + "backends": [ + "/bs/", + "/index-kv/" + ] + } + }, + "/bs-and-maybe-also-index/": { + "handler": "storage-cond", + "handlerArgs": { + "read": "/bs/", + "write": { + "else": "/bs/", + "if": "isSchema", + "then": "/bs-and-index/" + } + } + }, + "/bs/": { + "handler": "storage-filesystem", + "handlerArgs": { + "path": "/tmp/blobs" + } + }, + "/cache/": { + "handler": "storage-filesystem", + "handlerArgs": { + "path": "/tmp/blobs/cache" + } + }, + "/index-kv/": { + "handler": "storage-kvfileindexer", + "handlerArgs": { + "blobSource": "/bs/", + "file": "/path/to/indexkv.db" + } + }, + "/my-search/": { + "handler": "search", + "handlerArgs": { + "index": "/index-kv/", + "owner": "sha1-f2b0b7da718b97ce8c31591d8ed4645c777f3ef4", + "slurpToMemory": true + } + }, + + "/pics/": { + "handler": "publish", + "handlerArgs": { + "blobRoot": "/bs-and-maybe-also-index/", + "cache": "/cache/", + "css": [ + "pics.css" + ], + "goTemplate": "gallery.html", + "js": [ + "pics.js" + ], + "rootName": "picsRoot", + "rootPermanode": [ + "/sighelper/", + "sha1-046c6aae4ec8245dfe63edc4a2abb407824a4b5a" + ], + "scaledImage": { + "file": "/tmp/camli-cache/pics-thumbnails.kv", + "type": "kv" + }, + "searchRoot": "/my-search/" + } + }, + "/music/": { + "handler": "publish", + "handlerArgs": { + "blobRoot": "/bs-and-maybe-also-index/", + "cache": "/cache/", + "css": [ + "pics.css" + ], + "goTemplate": "gallery.html", + "js": [ + "pics.js" + ], + "rootName": "musicRoot", + "rootPermanode": [ + "/sighelper/", + "sha1-999c6aae4ec8245dfe63edc4a2abb407824a4b5a" + ], + "scaledImage": { + "file": "/tmp/camli-cache/music-thumbnails.kv", + "type": "kv" + }, + "searchRoot": "/my-search/" + } + }, + "/setup/": { + "handler": "setup" + }, + "/share/": { + "handler": "share", + "handlerArgs": { + "blobRoot": "/bs/" + } + }, + "/sighelper/": { + "handler": "jsonsign", + "handlerArgs": { + "keyId": "26F5ABDA", + "publicKeyDest": "/bs-and-index/", + "secretRing": "/path/to/secring" + } + }, + "/status/": { + "handler": "status" + }, + "/sync/": { + "handler": "sync", + "handlerArgs": { + "from": "/bs/", + "queue": { + "file": "/tmp/blobs/sync-to-index-queue.kv", + "type": "kv" + }, + "to": "/index-kv/" + } + }, + "/ui/": { + "handler": "ui", + "handlerArgs": { + "cache": "/cache/", + "jsonSignRoot": "/sighelper/", + "publishRoots": [ + "/pics/", + "/music/" + ], + "scaledImage": { + "file": "/tmp/blobs/thumbmeta.kv", + "type": "kv" + } + } + } + } +} diff --git a/pkg/serverinit/testdata/multipublish.json b/pkg/serverinit/testdata/multipublish.json new file mode 100644 index 000000000..4ce1f8523 --- /dev/null +++ b/pkg/serverinit/testdata/multipublish.json @@ -0,0 +1,24 @@ +{ + "listen": "localhost:3179", + "auth": "userpass:camlistore:pass3179", + "blobPath": "/tmp/blobs", + "kvIndexFile": "/path/to/indexkv.db", + "identity": "26F5ABDA", + "identitySecretRing": "/path/to/secring", + "ownerName": "Alice", + "shareHandlerPath": "/share/", + "publish": { + "/pics/": { + "rootPermanode": "sha1-046c6aae4ec8245dfe63edc4a2abb407824a4b5a", + "style": "pics.css", + "js": "pics.js", + "goTemplate": "gallery.html" + }, + "/music/": { + "rootPermanode": "sha1-999c6aae4ec8245dfe63edc4a2abb407824a4b5a", + "style": "pics.css", + "js": "pics.js", + "goTemplate": "gallery.html" + } + } +} diff --git a/pkg/serverinit/testdata/with_blog-want.json b/pkg/serverinit/testdata/with_blog-want.json index 93782364f..4e2969447 100644 --- a/pkg/serverinit/testdata/with_blog-want.json +++ b/pkg/serverinit/testdata/with_blog-want.json @@ -28,7 +28,7 @@ ], "scaledImage": { "type": "kv", - "file": "/tmp/camli-cache/thumbnails.kv" + "file": "/tmp/camli-cache/blog-thumbnails.kv" }, "searchRoot": "/my-search/" } diff --git a/pkg/serverinit/testdata/with_gallery-want.json b/pkg/serverinit/testdata/with_gallery-want.json index 5bfd3eb8e..53511d591 100644 --- a/pkg/serverinit/testdata/with_gallery-want.json +++ b/pkg/serverinit/testdata/with_gallery-want.json @@ -78,7 +78,7 @@ ], "scaledImage": { "type": "kv", - "file": "/tmp/camli-cache/thumbnails.kv" + "file": "/tmp/camli-cache/pics-thumbnails.kv" }, "searchRoot": "/my-search/" }