mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-05 07:23:21 +02:00
Update PR
Update PR
This commit is contained in:
parent
820e4b1e39
commit
5c04e35a3a
10
src/config.d
10
src/config.d
|
@ -134,7 +134,7 @@ final class Config
|
||||||
// display_sync_options = true | false
|
// display_sync_options = true | false
|
||||||
// - It may be desirable to see what options are being passed in to performSync() without enabling the full verbose debug logging
|
// - It may be desirable to see what options are being passed in to performSync() without enabling the full verbose debug logging
|
||||||
boolValues["display_sync_options"] = false;
|
boolValues["display_sync_options"] = false;
|
||||||
|
|
||||||
// Determine the users home directory.
|
// Determine the users home directory.
|
||||||
// Need to avoid using ~ here as expandTilde() below does not interpret correctly when running under init.d or systemd scripts
|
// Need to avoid using ~ here as expandTilde() below does not interpret correctly when running under init.d or systemd scripts
|
||||||
// Check for HOME environment variable
|
// Check for HOME environment variable
|
||||||
|
@ -304,7 +304,7 @@ final class Config
|
||||||
boolValues["synchronize"] = false;
|
boolValues["synchronize"] = false;
|
||||||
boolValues["force"] = false;
|
boolValues["force"] = false;
|
||||||
boolValues["list_business_shared_folders"] = false;
|
boolValues["list_business_shared_folders"] = false;
|
||||||
|
|
||||||
// Application Startup option validation
|
// Application Startup option validation
|
||||||
try {
|
try {
|
||||||
string tmpStr;
|
string tmpStr;
|
||||||
|
@ -465,7 +465,11 @@ final class Config
|
||||||
&boolValues["list_business_shared_folders"],
|
&boolValues["list_business_shared_folders"],
|
||||||
"sync-shared-folders",
|
"sync-shared-folders",
|
||||||
"Sync OneDrive Business Shared Folders",
|
"Sync OneDrive Business Shared Folders",
|
||||||
&boolValues["sync_business_shared_folders"]
|
&boolValues["sync_business_shared_folders"],
|
||||||
|
"export-translations",
|
||||||
|
"Export existing default application messages in JSON format",
|
||||||
|
&tmpBol
|
||||||
|
|
||||||
);
|
);
|
||||||
if (opt.helpWanted) {
|
if (opt.helpWanted) {
|
||||||
outputLongHelp(opt.options);
|
outputLongHelp(opt.options);
|
||||||
|
|
10
src/itemdb.d
10
src/itemdb.d
|
@ -6,6 +6,7 @@ import std.stdio;
|
||||||
import std.algorithm.searching;
|
import std.algorithm.searching;
|
||||||
import core.stdc.stdlib;
|
import core.stdc.stdlib;
|
||||||
import sqlite;
|
import sqlite;
|
||||||
|
import translations;
|
||||||
static import log;
|
static import log;
|
||||||
|
|
||||||
enum ItemType {
|
enum ItemType {
|
||||||
|
@ -42,16 +43,21 @@ final class ItemDatabase
|
||||||
string selectItemByIdStmt;
|
string selectItemByIdStmt;
|
||||||
string selectItemByParentIdStmt;
|
string selectItemByParentIdStmt;
|
||||||
string deleteItemByIdStmt;
|
string deleteItemByIdStmt;
|
||||||
|
string languageIdentifier;
|
||||||
|
|
||||||
this(const(char)[] filename)
|
this(const(char)[] filename)
|
||||||
{
|
{
|
||||||
|
languageIdentifier = getConfigLanguageIdentifier();
|
||||||
|
|
||||||
|
writeln("itemdb.d languageIdentifier: ", languageIdentifier);
|
||||||
|
|
||||||
db = Database(filename);
|
db = Database(filename);
|
||||||
int dbVersion;
|
int dbVersion;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
dbVersion = db.getVersion();
|
dbVersion = db.getVersion();
|
||||||
} catch (SqliteException e) {
|
} catch (SqliteException e) {
|
||||||
// An error was generated - what was the error?
|
// An error was generated - what was the error?
|
||||||
// "\nAn internal database error occurred: " ~ e.msg ~ "\n"
|
|
||||||
log.error(provideLanguageTranslation(languageIdentifier,331) ~ e.msg ~ "\n");
|
log.error(provideLanguageTranslation(languageIdentifier,331) ~ e.msg ~ "\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
21
src/main.d
21
src/main.d
|
@ -114,12 +114,16 @@ int main(string[] args)
|
||||||
string helpMessage = "Please use 'onedrive --help' for further assistance in regards to running this application";
|
string helpMessage = "Please use 'onedrive --help' for further assistance in regards to running this application";
|
||||||
try {
|
try {
|
||||||
bool printVersion = false;
|
bool printVersion = false;
|
||||||
|
bool exportTranslations = false;
|
||||||
auto opt = getopt(
|
auto opt = getopt(
|
||||||
args,
|
args,
|
||||||
std.getopt.config.passThrough,
|
std.getopt.config.passThrough,
|
||||||
std.getopt.config.bundling,
|
std.getopt.config.bundling,
|
||||||
std.getopt.config.caseSensitive,
|
std.getopt.config.caseSensitive,
|
||||||
"confdir", "Set the directory used to store the configuration files", &confdirOption,
|
"confdir", "Set the directory used to store the configuration files", &confdirOption,
|
||||||
|
|
||||||
|
"export-translations", "Export existing default application messages in JSON format", &exportTranslations,
|
||||||
|
|
||||||
"verbose|v+", "Print more details, useful for debugging (repeat for extra debugging)", &log.verbose,
|
"verbose|v+", "Print more details, useful for debugging (repeat for extra debugging)", &log.verbose,
|
||||||
"version", "Print the version and exit", &printVersion
|
"version", "Print the version and exit", &printVersion
|
||||||
);
|
);
|
||||||
|
@ -132,6 +136,17 @@ int main(string[] args)
|
||||||
writeln("onedrive ", strip(import("version")));
|
writeln("onedrive ", strip(import("version")));
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we are dumping the existing default application messages in JSON format, do so, then exit
|
||||||
|
if (exportTranslations){
|
||||||
|
// EN only message
|
||||||
|
writeln("Exporting existing application messages in JSON format");
|
||||||
|
// Export application default messages
|
||||||
|
exportDefaultMessages();
|
||||||
|
// exit
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
} catch (GetOptException e) {
|
} catch (GetOptException e) {
|
||||||
// option errors
|
// option errors
|
||||||
log.error(e.msg);
|
log.error(e.msg);
|
||||||
|
@ -154,7 +169,7 @@ int main(string[] args)
|
||||||
// Error message already printed
|
// Error message already printed
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --verbose --verbose used .. override any language setting to force EN-AU
|
// --verbose --verbose used .. override any language setting to force EN-AU
|
||||||
if (cfg.getValueLong("verbose") >= 2) {
|
if (cfg.getValueLong("verbose") >= 2) {
|
||||||
log.vdebug("Force application language to EN-AU due to debug operation");
|
log.vdebug("Force application language to EN-AU due to debug operation");
|
||||||
|
@ -162,7 +177,9 @@ int main(string[] args)
|
||||||
}
|
}
|
||||||
// Use the configured application language
|
// Use the configured application language
|
||||||
languageIdentifier = cfg.getValueString("language_identifier");
|
languageIdentifier = cfg.getValueString("language_identifier");
|
||||||
log.vlog("Application Language set to: ", languageIdentifier);
|
// Set the language identifier for wider use
|
||||||
|
setConfigLanguageIdentifier(languageIdentifier);
|
||||||
|
log.log("Application Language set to: ", languageIdentifier);
|
||||||
|
|
||||||
// set memory display
|
// set memory display
|
||||||
displayMemoryUsage = cfg.getValueBool("display_memory");
|
displayMemoryUsage = cfg.getValueBool("display_memory");
|
||||||
|
|
|
@ -6,6 +6,7 @@ import core.stdc.stdlib;
|
||||||
import config;
|
import config;
|
||||||
import selective;
|
import selective;
|
||||||
import util;
|
import util;
|
||||||
|
import translations;
|
||||||
static import log;
|
static import log;
|
||||||
|
|
||||||
// relevant inotify events
|
// relevant inotify events
|
||||||
|
@ -21,6 +22,7 @@ class MonitorException: ErrnoException
|
||||||
|
|
||||||
final class Monitor
|
final class Monitor
|
||||||
{
|
{
|
||||||
|
// verbosity flag
|
||||||
bool verbose;
|
bool verbose;
|
||||||
// inotify file descriptor
|
// inotify file descriptor
|
||||||
private int fd;
|
private int fd;
|
||||||
|
@ -34,6 +36,7 @@ final class Monitor
|
||||||
bool skip_symlinks;
|
bool skip_symlinks;
|
||||||
// check for .nosync if enabled
|
// check for .nosync if enabled
|
||||||
bool check_nosync;
|
bool check_nosync;
|
||||||
|
string languageIdentifier;
|
||||||
|
|
||||||
private SelectiveSync selectiveSync;
|
private SelectiveSync selectiveSync;
|
||||||
|
|
||||||
|
@ -53,6 +56,9 @@ final class Monitor
|
||||||
this.verbose = verbose;
|
this.verbose = verbose;
|
||||||
this.skip_symlinks = skip_symlinks;
|
this.skip_symlinks = skip_symlinks;
|
||||||
this.check_nosync = check_nosync;
|
this.check_nosync = check_nosync;
|
||||||
|
this.languageIdentifier = getConfigLanguageIdentifier();
|
||||||
|
|
||||||
|
writeln("monitor.d languageIdentifier: ", languageIdentifier);
|
||||||
|
|
||||||
assert(onDirCreated && onFileChanged && onDelete && onMove);
|
assert(onDirCreated && onFileChanged && onDelete && onMove);
|
||||||
fd = inotify_init();
|
fd = inotify_init();
|
||||||
|
|
|
@ -54,22 +54,21 @@ struct Database
|
||||||
|
|
||||||
void dump_open_statements()
|
void dump_open_statements()
|
||||||
{
|
{
|
||||||
log.log("Dumpint open statements: \n");
|
writeln("Dumping open SQL statements: \n");
|
||||||
auto p = sqlite3_next_stmt(pDb, null);
|
auto p = sqlite3_next_stmt(pDb, null);
|
||||||
while (p != null) {
|
while (p != null) {
|
||||||
log.log (" - " ~ ifromStringz(sqlite3_sql(p)) ~ "\n");
|
writeln(" - " ~ ifromStringz(sqlite3_sql(p)) ~ "\n");
|
||||||
p = sqlite3_next_stmt(pDb, p);
|
p = sqlite3_next_stmt(pDb, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void open(const(char)[] filename)
|
void open(const(char)[] filename)
|
||||||
{
|
{
|
||||||
// https://www.sqlite.org/c3ref/open.html
|
// https://www.sqlite.org/c3ref/open.html
|
||||||
int rc = sqlite3_open(toStringz(filename), &pDb);
|
int rc = sqlite3_open(toStringz(filename), &pDb);
|
||||||
if (rc == SQLITE_CANTOPEN) {
|
if (rc == SQLITE_CANTOPEN) {
|
||||||
// Database cannot be opened
|
// Database cannot be opened
|
||||||
log.error("\nThe database cannot be opened. Please check the permissions of ~/.config/onedrive/items.sqlite3\n");
|
log.error("\nThe database cannot be opened. Please check the permissions of " ~ filename ~ "\n");
|
||||||
close();
|
close();
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -296,7 +296,9 @@ final class SyncEngine
|
||||||
JSONValue oneDriveRootDetails;
|
JSONValue oneDriveRootDetails;
|
||||||
|
|
||||||
// Update language identifier as used with this class
|
// Update language identifier as used with this class
|
||||||
languageIdentifier = cfg.getValueString("language_identifier");
|
languageIdentifier = getConfigLanguageIdentifier();
|
||||||
|
|
||||||
|
writeln("sync.d languageIdentifier: ", languageIdentifier);
|
||||||
|
|
||||||
if (initDone) {
|
if (initDone) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -10,14 +10,33 @@ ulong defaultMessageCount = 0;
|
||||||
string[] languageResponsesDefault;
|
string[] languageResponsesDefault;
|
||||||
string[] languageResponsesTranslations;
|
string[] languageResponsesTranslations;
|
||||||
string defaultBadLookupResponse = "ERROR: BAD LOOKUP INDEX FOR LANGUAGE TRANSLATION";
|
string defaultBadLookupResponse = "ERROR: BAD LOOKUP INDEX FOR LANGUAGE TRANSLATION";
|
||||||
|
JSONValue languageListDefault;
|
||||||
|
string configLanguageIdentifier;
|
||||||
|
|
||||||
// Initialise default message lookup using EN-AU
|
// Initialise default message lookup using EN-AU
|
||||||
void initialize() {
|
void initialize() {
|
||||||
// Initialise default messages
|
// Initialise default messages
|
||||||
initialise_EN_AU();
|
initialise_defaults();
|
||||||
defaultMessageCount = count(languageResponsesDefault);
|
defaultMessageCount = count(languageResponsesDefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void exportDefaultMessages() {
|
||||||
|
// Initialise default messages
|
||||||
|
initialise_defaults();
|
||||||
|
// Print JSON Array
|
||||||
|
writeln(languageListDefault);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setConfigLanguageIdentifier(string languageIdentifier) {
|
||||||
|
// set the local variable
|
||||||
|
configLanguageIdentifier = languageIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
string getConfigLanguageIdentifier() {
|
||||||
|
// return the current set language identifier as per config or set by user
|
||||||
|
return configLanguageIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
// Load user configured translation files from a file
|
// Load user configured translation files from a file
|
||||||
void initializeUserConfiguredLanguageTranslations(string languageIdentifier) {
|
void initializeUserConfiguredLanguageTranslations(string languageIdentifier) {
|
||||||
// Path to translation files
|
// Path to translation files
|
||||||
|
@ -148,10 +167,12 @@ string getResponseFromIndex(int requiredResponseIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load EN-AU application messages
|
// Load EN-AU application messages
|
||||||
void initialise_EN_AU(){
|
void initialise_defaults(){
|
||||||
// The below JSON array contains all the default application messages
|
// The below JSON array contains all the default application messages
|
||||||
JSONValue languageList = [ "language": "EN-AU"];
|
// Default Language Type
|
||||||
languageList.object["list"] = JSONValue([
|
languageListDefault = [ "language": "EN-AU"];
|
||||||
|
// Application Messages
|
||||||
|
languageListDefault.object["list"] = JSONValue([
|
||||||
JSONValue([ "1": "No user or system config file found, using application defaults" ]),
|
JSONValue([ "1": "No user or system config file found, using application defaults" ]),
|
||||||
JSONValue([ "2": "System configuration file successfully loaded" ]),
|
JSONValue([ "2": "System configuration file successfully loaded" ]),
|
||||||
JSONValue([ "3": "System configuration file has errors - please check your configuration" ]),
|
JSONValue([ "3": "System configuration file has errors - please check your configuration" ]),
|
||||||
|
@ -484,7 +505,6 @@ void initialise_EN_AU(){
|
||||||
JSONValue([ "330": "Removed this directory from being monitored for local changes: " ]),
|
JSONValue([ "330": "Removed this directory from being monitored for local changes: " ]),
|
||||||
JSONValue([ "331": "\nAn internal database error occurred: " ]),
|
JSONValue([ "331": "\nAn internal database error occurred: " ]),
|
||||||
JSONValue([ "332": "The item database is incompatible, re-creating database table structures" ]),
|
JSONValue([ "332": "The item database is incompatible, re-creating database table structures" ]),
|
||||||
JSONValue([ "330": "Removed this directory from being monitored for local changes: " ]),
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -492,7 +512,7 @@ void initialise_EN_AU(){
|
||||||
|
|
||||||
// Load the message into the array
|
// Load the message into the array
|
||||||
ulong thisMessageID = 0;
|
ulong thisMessageID = 0;
|
||||||
foreach (translationItem; languageList["list"].array) {
|
foreach (translationItem; languageListDefault["list"].array) {
|
||||||
thisMessageID++;
|
thisMessageID++;
|
||||||
string responseString = translationItem[to!string(thisMessageID)].str;
|
string responseString = translationItem[to!string(thisMessageID)].str;
|
||||||
languageResponsesDefault ~= responseString;
|
languageResponsesDefault ~= responseString;
|
||||||
|
|
Loading…
Reference in a new issue