diff --git a/dev-server b/dev-server index 9eb8baf39..534708af1 100755 --- a/dev-server +++ b/dev-server @@ -14,6 +14,7 @@ my $opt_wipe; my $opt_tls; my $opt_nobuild; my $opt_all; # listen on all interfaces +my $opt_staticres; # use static resources, not those on disk # keep indexes in memory only. often used with --wipe, but not # necessarily. if --wipe isn't used, all blobs are re-indexed @@ -28,6 +29,7 @@ GetOptions("wipe" => \$opt_wipe, "memory" => \$opt_memory, "mongo" => \$opt_mongo, "mysql" => \$opt_mysql, + "staticres" => \$opt_staticres, ) or usage(); @@ -125,7 +127,9 @@ $ENV{CAMLI_DBNAME} = $DBNAME; # To use resources from disk, instead of the copies linked into the # binary: -$ENV{CAMLI_DEV_UI_FILES} = "$FindBin::Bin/server/go/camlistored/ui"; # set in server/go/camlistored/ui/fileembed.go +unless ($opt_staticres) { + $ENV{CAMLI_DEV_UI_FILES} = "$FindBin::Bin/server/camlistored/ui"; # set in server/camlistored/ui/fileembed.go +} exec("./gopath/bin/camlistored", "-configfile=$Bin/config/dev-server-config.json", diff --git a/pkg/fileembed/fileembed.go b/pkg/fileembed/fileembed.go index 7d4b8a5d9..a5df6131d 100644 --- a/pkg/fileembed/fileembed.go +++ b/pkg/fileembed/fileembed.go @@ -23,6 +23,7 @@ import ( "net/http" "os" "path/filepath" + "strings" "sync" "time" ) @@ -67,9 +68,15 @@ func (f *Files) add(filename string, sf *staticFile) { f.file[filename] = sf } -func (f *Files) Open(filename string) (http.File, error) { +var _ http.FileSystem = (*Files)(nil) + +func (f *Files) Open(filename string) (hf http.File, err error) { + if strings.HasPrefix(filename, "/") { + filename = filename[1:] + } if e := f.OverrideEnv; e != "" && os.Getenv(e) != "" { - return os.Open(filepath.Join(os.Getenv(e), filename)) + diskPath := filepath.Join(os.Getenv(e), filename) + return os.Open(diskPath) } f.lk.Lock() defer f.lk.Unlock()