mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-15 20:25:18 +02:00
added logout cmd line option
This commit is contained in:
parent
738536736a
commit
c91decaa16
16
src/main.d
16
src/main.d
|
@ -12,6 +12,8 @@ int main(string[] args)
|
|||
bool monitor;
|
||||
// force a full resync
|
||||
bool resync;
|
||||
// remove the current user and sync state
|
||||
bool logout;
|
||||
// enable verbose logging
|
||||
bool verbose;
|
||||
|
||||
|
@ -21,7 +23,8 @@ int main(string[] args)
|
|||
std.getopt.config.bundling,
|
||||
"monitor|m", "Keep monitoring for local and remote changes.", &monitor,
|
||||
"resync", "Forget the last saved state, perform a full sync.", &resync,
|
||||
"confdir", "Directory to use to store the configuration files.", &configDirName,
|
||||
"logout", "Logout the current user.", &logout,
|
||||
"confdir", "Set the directory to use to store the configuration files.", &configDirName,
|
||||
"verbose|v", "Print more details, useful for debugging.", &log.verbose
|
||||
);
|
||||
if (opt.helpWanted) {
|
||||
|
@ -39,13 +42,18 @@ int main(string[] args)
|
|||
}
|
||||
|
||||
log.vlog("Loading config ...");
|
||||
configDirName = expandTilde(configDirName);
|
||||
if (!exists(configDirName)) mkdir(configDirName);
|
||||
auto cfg = new config.Config(configDirName);
|
||||
cfg.init();
|
||||
if (resync) {
|
||||
if (resync || logout) {
|
||||
log.log("Deleting the saved status ...");
|
||||
if (exists(cfg.databaseFilePath)) remove(cfg.databaseFilePath);
|
||||
if (exists(cfg.statusTokenFilePath)) remove(cfg.statusTokenFilePath);
|
||||
safeRemove(cfg.databaseFilePath);
|
||||
safeRemove(cfg.statusTokenFilePath);
|
||||
safeRemove(cfg.uploadStateFilePath);
|
||||
if (logout) {
|
||||
safeRemove(cfg.refreshTokenFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
log.vlog("Initializing the OneDrive API ...");
|
||||
|
|
|
@ -32,6 +32,12 @@ void safeRename(const(char)[] path)
|
|||
rename(path, newPath);
|
||||
}
|
||||
|
||||
// delete the specified file without throwing an exception if it does not exists
|
||||
void safeRemove(const(char)[] path)
|
||||
{
|
||||
if (exists(path)) remove(path);
|
||||
}
|
||||
|
||||
// return the crc32 hex string of a file
|
||||
string computeCrc32(string path)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue