Skip to content

Commit

Permalink
Close #252
Browse files Browse the repository at this point in the history
Remove xdg_base_directory config option
  • Loading branch information
astrada committed Feb 5, 2017
1 parent 7ce69d0 commit ecbd284
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 38 deletions.
17 changes: 9 additions & 8 deletions src/appDir.ml
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,22 @@ let xdg_cache_home =
let get_config_path config_path xdg_base_directory base_dir fs_label =
let xdg_config_dir = xdg_config_home // "gdfuse" // fs_label in
let xdg_config_path = xdg_config_dir // "config" in
if config_path <> "" then config_path
if config_path <> "" then (config_path, false)
else if xdg_base_directory then begin
Utils.safe_makedir xdg_config_dir;
xdg_config_path
end else if Sys.file_exists xdg_config_path then xdg_config_path
(xdg_config_path, true)
end else if Sys.file_exists xdg_config_path then
(xdg_config_path, true)
else
let base_dir =
if base_dir = "" then default_base_dir else base_dir in
base_dir // fs_label // "config"
(base_dir // fs_label // "config", false)

let create config_path config base_dir fs_label =
let create config config_path base_dir fs_label xdg_base_directory =
let data_dir =
if config.Config.data_directory <> "" then
config.Config.data_directory
else if config.Config.xdg_base_directory then
else if xdg_base_directory then
xdg_data_home // "gdfuse" // fs_label
else
let base_dir =
Expand All @@ -90,12 +91,12 @@ let create config_path config base_dir fs_label =
let cache_dir =
if config.Config.cache_directory <> "" then
config.Config.cache_directory
else if config.Config.xdg_base_directory then
else if xdg_base_directory then
xdg_cache_home // "gdfuse" // fs_label
else data_dir // "cache" in
let log_dir =
if config.Config.log_directory <> "" then config.Config.log_directory
else if config.Config.xdg_base_directory then cache_dir // "log"
else if xdg_base_directory then cache_dir // "log"
else data_dir in
{ config_path;
data_dir;
Expand Down
12 changes: 0 additions & 12 deletions src/config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ type t = {
lost_and_found : bool;
(* Fetch shared files and make them available in .shared *)
shared_with_me : bool;
(* Enable XDG Base Directory support *)
xdg_base_directory : bool;
(* Path of the directory storing application state *)
data_directory : string;
(* Path of the directory storing application cache *)
Expand Down Expand Up @@ -293,10 +291,6 @@ let shared_with_me = {
GapiLens.get = (fun x -> x.shared_with_me);
GapiLens.set = (fun v x -> { x with shared_with_me = v })
}
let xdg_base_directory = {
GapiLens.get = (fun x -> x.xdg_base_directory);
GapiLens.set = (fun v x -> { x with xdg_base_directory = v })
}
let data_directory = {
GapiLens.get = (fun x -> x.data_directory);
GapiLens.set = (fun v x -> { x with data_directory = v })
Expand Down Expand Up @@ -371,7 +365,6 @@ let default = {
read_ahead_buffers = 3;
lost_and_found = false;
shared_with_me = false;
xdg_base_directory = false;
data_directory = "";
cache_directory = "";
log_directory = "";
Expand Down Expand Up @@ -423,7 +416,6 @@ let default_debug = {
read_ahead_buffers = 3;
lost_and_found = false;
shared_with_me = false;
xdg_base_directory = false;
data_directory = "";
cache_directory = "";
log_directory = "";
Expand Down Expand Up @@ -524,9 +516,6 @@ let of_table table =
shared_with_me =
get "shared_with_me" bool_of_string
default.shared_with_me;
xdg_base_directory =
get "xdg_base_directory" bool_of_string
default.xdg_base_directory;
data_directory =
get "data_directory" Std.identity
default.data_directory;
Expand Down Expand Up @@ -589,7 +578,6 @@ let to_table data =
add "read_ahead_buffers" (data.read_ahead_buffers |> string_of_int);
add "lost_and_found" (data.lost_and_found |> string_of_bool);
add "shared_with_me" (data.shared_with_me |> string_of_bool);
add "xdg_base_directory" (data.xdg_base_directory |> string_of_bool);
add "data_directory" data.data_directory;
add "cache_directory" data.cache_directory;
add "log_directory" data.log_directory;
Expand Down
27 changes: 9 additions & 18 deletions src/gdfuse.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,10 @@ let rng =
string dev_rng 20 |> pseudo_rng

(* Application configuration *)
let create_default_config_store debug xdg_base_directory path =
let config =
let create_default_config_store debug path =
let data =
if debug then Config.default_debug
else Config.default in
let data =
{ config with
Config.xdg_base_directory
} in
(* Save configuration file *)
let config_store = {
Context.ConfigFileStore.path;
Expand All @@ -42,15 +38,15 @@ let create_default_config_store debug xdg_base_directory path =
Context.save_config_store config_store;
config_store

let get_config_store debug xdg_base_directory config_path =
let get_config_store debug config_path =
try
Utils.log_with_header "Loading configuration from %s..." config_path;
let config_store = Context.ConfigFileStore.load config_path in
Utils.log_message "done\n";
config_store
with KeyValueStore.File_not_found ->
Utils.log_message "not found.\n";
create_default_config_store debug xdg_base_directory config_path
create_default_config_store debug config_path
(* END Application configuration *)

(* Application state *)
Expand Down Expand Up @@ -137,27 +133,22 @@ let setup_application params =
Utils.log_message "Starting application setup (label=%s, base_dir=%s).\n%!"
params.filesystem_label
params.base_dir;
let config_path =
let (config_path, xdg_base_directory) =
AppDir.get_config_path
params.config_path
params.xdg_base_directory
params.base_dir
params.filesystem_label in
let config_store =
get_config_store params.debug params.xdg_base_directory config_path in
get_config_store params.debug config_path in
let current_config = config_store.Context.ConfigFileStore.data in
let current_config =
if params.xdg_base_directory then
{ current_config with
Config.xdg_base_directory = params.xdg_base_directory
}
else current_config in
let app_dir =
AppDir.create
params.config_path
current_config
params.config_path
params.base_dir
params.filesystem_label in
params.filesystem_label
xdg_base_directory in
let () = AppDir.create_directories app_dir in
let app_log_path = app_dir.AppDir.app_log_path in
Utils.log_message "Opening log file: %s\n%!" app_log_path;
Expand Down

0 comments on commit ecbd284

Please sign in to comment.