diff --git a/client/pages/filespage/submenu.js b/client/pages/filespage/submenu.js
index 67497ba4..98c2b894 100644
--- a/client/pages/filespage/submenu.js
+++ b/client/pages/filespage/submenu.js
@@ -139,7 +139,7 @@ export class Submenu extends React.Component {
-
+
-
+
diff --git a/server/common/config.go b/server/common/config.go
index ac7eb56e..4cdaf48c 100644
--- a/server/common/config.go
+++ b/server/common/config.go
@@ -354,7 +354,6 @@ func (this Configuration) Export() interface{} {
RememberMe bool `json:"remember_me"`
UploadButton bool `json:"upload_button"`
Connections interface{} `json:"connections"`
- EnableSearch bool `json:"enable_search"`
EnableShare bool `json:"enable_share"`
MimeTypes map[string]string `json:"mime"`
}{
@@ -366,7 +365,6 @@ func (this Configuration) Export() interface{} {
RememberMe: this.Get("general.remember_me").Bool(),
UploadButton: this.Get("general.upload_button").Bool(),
Connections: this.Conn,
- EnableSearch: this.Get("features.search.enable").Bool(),
EnableShare: this.Get("features.share.enable").Bool(),
MimeTypes: AllMimeTypes(),
}
diff --git a/server/ctrl/search.go b/server/ctrl/search.go
index 26995eb8..54bfa240 100644
--- a/server/ctrl/search.go
+++ b/server/ctrl/search.go
@@ -8,11 +8,6 @@ import (
)
func FileSearch(ctx App, res http.ResponseWriter, req *http.Request) {
- if Config.Get("features.search.enable").Bool() == false {
- SendErrorResult(res, ErrNotAllowed)
- return
- }
-
path, err := PathBuilder(ctx, req.URL.Query().Get("path"))
if err != nil {
path = "/"
@@ -22,10 +17,20 @@ func FileSearch(ctx App, res http.ResponseWriter, req *http.Request) {
SendErrorResult(res, ErrPermissionDenied)
return
}
- searchResults := model.Search(&ctx, path, q)
- for i:=0; i 4 {
+ return 4
+ }
+ }
+ return s
+}
+
+func scoreBoostOnDepth(p string) int {
+ return - strings.Count(p, "/")
+}
+
+func SearchStateLess(app *App, path string, keyword string) []File {
+ files := make([]File, 0)
+ toVisit := []PathQuandidate{PathQuandidate{path, 0}}
+ MAX_SEARCH_TIME := 300 * time.Millisecond
+
+ for start := time.Now() ; time.Since(start) < MAX_SEARCH_TIME; {
+ if len(toVisit) == 0 {
+ return files
+ }
+ currentPath := toVisit[0]
+ if len(toVisit) == 0 {
+ toVisit = make([]PathQuandidate, 0)
+ } else {
+ toVisit = toVisit[1:]
+ }
+
+ // Ls on the directory
+ f, err := app.Backend.Ls(currentPath.Path)
+ if err != nil {
+ continue
+ }
+
+ score1 := scoreBoostForFilesInDirectory(f)
+ for i:=0; i toVisit[k].Score {
+ break
+ }
+ t[k] = toVisit[k]
+ }
+ t[k] = PathQuandidate{fullpath, score}
+ for k=k+1; k