Merged from upstream

This commit is contained in:
Robert Foster 2018-07-11 06:40:37 +10:00
commit 4c1b445170
6 changed files with 47 additions and 5 deletions

1
.gitignore vendored
View file

@ -2,5 +2,6 @@
onedrive
onedrive.o
onedrive.service
onedrive@.service
version
onedrive@.service

View file

@ -19,7 +19,7 @@ SOURCES = \
all: onedrive onedrive.service
clean:
rm -f onedrive onedrive.o onedrive.service
rm -f onedrive onedrive.o onedrive.service onedrive@.service
install: all
mkdir -p $(DESTDIR)/var/log/onedrive

View file

@ -166,11 +166,23 @@ mkdir -p ~/.config/onedrive
cp ./config ~/.config/onedrive/config
nano ~/.config/onedrive/config
```
This file does not get created by default, and should only be created if you want to change the 'default' operational parameters.
Available options:
* `sync_dir`: directory where the files will be synced
* `skip_file`: any files or directories that match this pattern will be skipped during sync.
### sync_dir
Example: `sync_dir="~/MyDirToSync"`
**Please Note:**
Proceed with caution here by changing the default sync dir from ~/OneDrive to ~/MyDirToSync
The issue here is around how the client stores the sync_dir path in the database. If the config file is missing, or you don't use the `--syncdir` parameter - what will happen is the client will default back to `~/OneDrive` and 'think' that either all your data has been deleted - thus delete the content on OneDrive, or will start downloading all data from OneDrive into the default location.
### skip_file
Example: `skip_file = ".*|~*|Desktop|Documents/OneNote*|Documents/IISExpress|Documents/SQL Server Management Studio|Documents/Visual Studio*|Documents/config.xlaunch|Documents/WindowsPowerShell"`
Patterns are case insensitive. `*` and `?` [wildcards characters](https://technet.microsoft.com/en-us/library/bb490639.aspx) are supported. Use `|` to separate multiple patterns.
Note: after changing `skip_file`, you must perform a full synchronization by executing `onedrive --resync`

View file

@ -117,7 +117,7 @@ int main(string[] args)
cfg.init();
// command line parameters override the config
if (syncDirName) cfg.setValue("sync_dir", syncDirName);
if (syncDirName) cfg.setValue("sync_dir", syncDirName.expandTilde().absolutePath());
// upgrades
if (exists(configDirName ~ "/items.db")) {

View file

@ -68,7 +68,7 @@ struct Database
{
int userVersion;
extern (C) int callback(void* user_version, int count, char** column_text, char** column_name) {
import core.stdc.stdlib;
import core.stdc.stdlib: atoi;
*(cast(int*) user_version) = atoi(*column_text);
return 0;
}

View file

@ -525,7 +525,9 @@ final class SyncEngine
// check if the item is going to be deleted
if (isItemDeleted(driveItem)) {
log.vlog("This item is marked for deletion:", item.name);
// item.name is not available, so we get a bunch of meaningless log output
// will fix this with wider logging changes being worked on
//log.vlog("This item is marked for deletion:", item.name);
if (cached) {
// flag to delete
idsToDelete ~= [item.driveId, item.id];
@ -839,6 +841,17 @@ final class SyncEngine
try {
response = onedrive.simpleUploadReplace(path, item.driveId, item.id, item.eTag);
} catch (OneDriveException e) {
// Resolve https://github.com/abraunegg/onedrive/issues/36
if ((e.httpStatusCode == 409) || (e.httpStatusCode == 423)) {
// The file is currently checked out or locked for editing by another user
// We cant upload this file at this time
writeln(" skipped.");
log.fileOnly("Uploading file ", path, " ... skipped.");
write("", path, " is currently checked out or locked for editing by another user.");
log.fileOnly(path, " is currently checked out or locked for editing by another user.");
return;
}
if (e.httpStatusCode == 504) {
// HTTP request returned status code 504 (Gateway Timeout)
// Try upload as a session
@ -855,7 +868,23 @@ final class SyncEngine
} else {
// OneDrive Business Account - always use a session to upload
writeln("");
response = session.upload(path, item.driveId, item.parentId, baseName(path));
try {
response = session.upload(path, item.driveId, item.parentId, baseName(path));
} catch (OneDriveException e) {
// Resolve https://github.com/abraunegg/onedrive/issues/36
if ((e.httpStatusCode == 409) || (e.httpStatusCode == 423)) {
// The file is currently checked out or locked for editing by another user
// We cant upload this file at this time
writeln(" skipped.");
log.fileOnly("Uploading file ", path, " ... skipped.");
writeln("", path, " is currently checked out or locked for editing by another user.");
log.fileOnly(path, " is currently checked out or locked for editing by another user.");
return;
}
}
writeln(" done.");
// As the session.upload includes the last modified time, save the response
saveItem(response);