Finished patching core/file
This commit is contained in:
parent
257038afe8
commit
03be845d60
@ -11,6 +11,11 @@ let note path = Lpath.fpath_of_note path |> load |> Note.of_string
|
||||
|
||||
type t = { repo_path : Lpath.repo_t }
|
||||
|
||||
let ext_len = String.length Lpath.extension
|
||||
let note_filename name =
|
||||
try Re_str.last_chars name ext_len = Lpath.extension with
|
||||
| Invalid_argument _ -> false
|
||||
|
||||
let to_list ?(order) lens_fn store =
|
||||
let repo_path = store.repo_path in
|
||||
let cons_valid_meta list path =
|
||||
@ -22,7 +27,7 @@ let to_list ?(order) lens_fn store =
|
||||
Lpath.string_of_repo repo_path
|
||||
|> Sys.readdir
|
||||
|> Array.to_list
|
||||
|> List.filter (fun filename -> BatString.ends_with file Lpath.extension) (* convert to paths first then check extention *)
|
||||
|> List.filter note_filename
|
||||
|> List.fold_left cons_valid_meta []
|
||||
|> match order with
|
||||
| Some fn -> List.fast_sort fn
|
||||
@ -41,7 +46,7 @@ let note_with_id store id =
|
||||
Lpath.string_of_repo repo_path
|
||||
|> Sys.readdir
|
||||
|> Array.to_list
|
||||
|> List.filter (fun file -> BatString.ends_with file Lpath.extension)
|
||||
|> List.filter note_filename
|
||||
in
|
||||
try Some (note_of_path (List.find with_id notes))
|
||||
with Not_found -> None
|
||||
@ -57,7 +62,7 @@ let note_with_alias store alias =
|
||||
Lpath.string_of_repo repo_path
|
||||
|> Sys.readdir
|
||||
|> Array.to_list
|
||||
|> List.filter (fun file -> BatString.ends_with file Lpath.extension)
|
||||
|> List.filter note_filename
|
||||
|> List.fold_left cons_valid_meta []
|
||||
|> List.filter (fun note -> Meta.alias note.Note.meta = alias)
|
||||
|> List.fast_sort (fun a b -> recency_order a.Note.meta b.Note.meta)
|
||||
|
Loading…
x
Reference in New Issue
Block a user