mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-29 10:50:30 +02:00
Merge branch 'master' into fix-issue-966
This commit is contained in:
commit
b84f3022bd
|
@ -28,6 +28,7 @@ notify_LIBS = @notify_LIBS@
|
|||
COMPLETIONS = @COMPLETIONS@
|
||||
BASH_COMPLETION_DIR = @BASH_COMPLETION_DIR@
|
||||
ZSH_COMPLETION_DIR = @ZSH_COMPLETION_DIR@
|
||||
FISH_COMPLETION_DIR = @FISH_COMPLETION_DIR@
|
||||
DEBUG = @DEBUG@
|
||||
|
||||
DC = @DC@
|
||||
|
@ -127,6 +128,7 @@ endif
|
|||
ifeq ($(COMPLETIONS),yes)
|
||||
$(INSTALL) -D -m 644 contrib/completions/complete.zsh $(DESTDIR)$(ZSH_COMPLETION_DIR)/_onedrive
|
||||
$(INSTALL) -D -m 644 contrib/completions/complete.bash $(DESTDIR)$(BASH_COMPLETION_DIR)/onedrive
|
||||
$(INSTALL) -D -m 644 contrib/completions/complete.fish $(DESTDIR)$(FISH_COMPLETION_DIR)/onedrive.fish
|
||||
endif
|
||||
|
||||
|
||||
|
@ -151,6 +153,7 @@ endif
|
|||
ifeq ($(COMPLETIONS),yes)
|
||||
rm -f $(DESTDIR)$(ZSH_COMPLETION_DIR)/_onedrive
|
||||
rm -f $(DESTDIR)$(BASH_COMPLETION_DIR)/onedrive
|
||||
rm -f $(DESTDIR)$(FISH_COMPLETION_DIR)/onedrive.fish
|
||||
endif
|
||||
|
||||
|
||||
|
|
22
configure
vendored
22
configure
vendored
|
@ -590,6 +590,7 @@ LIBOBJS
|
|||
DEBUG
|
||||
ZSH_COMPLETION_DIR
|
||||
BASH_COMPLETION_DIR
|
||||
FISH_COMPLETION_DIR
|
||||
bashcompdir
|
||||
COMPLETIONS
|
||||
NOTIFICATIONS
|
||||
|
@ -660,6 +661,7 @@ enable_notifications
|
|||
enable_completions
|
||||
with_bash_completion_dir
|
||||
with_zsh_completion_dir
|
||||
with_fish_completion_dir
|
||||
enable_debug
|
||||
'
|
||||
ac_precious_vars='build_alias
|
||||
|
@ -1289,7 +1291,7 @@ Optional Features:
|
|||
--disable-version-check Disable checks of compiler version during configure
|
||||
time
|
||||
--enable-notifications Enable desktop notifications via libnotify
|
||||
--enable-completions Install shell completions for bash and zsh
|
||||
--enable-completions Install shell completions for bash, zsh, and fish
|
||||
--enable-debug Pass debug option to the compiler
|
||||
|
||||
Optional Packages:
|
||||
|
@ -1303,6 +1305,8 @@ Optional Packages:
|
|||
Directory for bash completion files
|
||||
--with-zsh-completion-dir=DIR
|
||||
Directory for zsh completion files
|
||||
--with-fish-completion-dir=DIR
|
||||
Directory for fish completion files
|
||||
|
||||
Some influential environment variables:
|
||||
DC D compiler executable
|
||||
|
@ -2579,6 +2583,22 @@ fi
|
|||
ZSH_COMPLETION_DIR=$with_zsh_completion_dir
|
||||
|
||||
|
||||
|
||||
# Check whether --with-fish-completion-dir was given.
|
||||
if test "${with_fish_completion_dir+set}" = set; then :
|
||||
withval=$with_fish_completion_dir;
|
||||
else
|
||||
with_fish_completion_dir=auto
|
||||
fi
|
||||
|
||||
if test "x$with_fish_completion_dir" = "xyes" -o "x$with_fish_completion_dir" = "xauto"; then :
|
||||
|
||||
with_fish_completion_dir="/usr/share/fish/completions"
|
||||
|
||||
fi
|
||||
FISH_COMPLETION_DIR=$with_fish_completion_dir
|
||||
|
||||
|
||||
fi
|
||||
|
||||
# Check whether --enable-debug was given.
|
||||
|
|
35
contrib/completions/complete.fish
Normal file
35
contrib/completions/complete.fish
Normal file
|
@ -0,0 +1,35 @@
|
|||
# FISH completions for OneDrive Linux Client
|
||||
# License: GPLv3+ (as with the rest of the OneDrive Linux client project)
|
||||
|
||||
complete -c onedrive -f
|
||||
|
||||
complete -c onedrive -l check-for-nomount -d 'Check for the presence of .nosync in the syncdir root. If found, do not perform sync.'
|
||||
complete -c onedrive -l check-for-nosync -d 'Check for the presence of .nosync in each directory. If found, skip directory from sync.'
|
||||
complete -c onedrive -l create-directory -d 'Create a directory on OneDrive - no sync will be performed.'
|
||||
complete -c onedrive -l debug-https -d 'Debug OneDrive HTTPS communication.'
|
||||
complete -c onedrive -l disable-notifications -d 'Do not use desktop notifications in monitor mode.'
|
||||
complete -c onedrive -l disable-upload-validation -d 'Disable upload validation when uploading to OneDrive.'
|
||||
complete -c onedrive -l display-config -d 'Display what options the client will use as currently configured - no sync will be performed.'
|
||||
complete -c onedrive -l display-sync-status -d 'Display the sync status of the client - no sync will be performed.'
|
||||
complete -c onedrive -l download-only -d 'Only download remote changes.'
|
||||
complete -c onedrive -l dry-run -d 'Perform a trial sync with no changes made.'
|
||||
complete -c onedrive -l enable-logging -d 'Enable client activity to a separate log file.'
|
||||
complete -c onedrive -l force-http-1.1 -d 'Force the use of HTTP 1.1 for all operations.'
|
||||
complete -c onedrive -l force-http-2 -d 'Force the use of HTTP 2 for all operations.'
|
||||
complete -c onedrive -l get-O365-drive-id -d 'Query and return the Office 365 Drive ID for a given Office 365 SharePoint Shared Library.'
|
||||
complete -c onedrive -s h -l help -d 'Print help information.'
|
||||
complete -c onedrive -l local-first -d 'Synchronize from the local directory source first, before downloading changes from OneDrive.'
|
||||
complete -c onedrive -l logout -d 'Logout the current user.'
|
||||
complete -c onedrive -n "not __fish_seen_subcommand_from --synchronize" -a "-m --monitor" -d 'Keep monitoring for local and remote changes.'
|
||||
complete -c onedrive -l no-remote-delete -d 'Do not delete local file deletes from OneDrive when using --upload-only.'
|
||||
complete -c onedrive -l print-token -d 'Print the access token, useful for debugging.'
|
||||
complete -c onedrive -l remote-directory -d 'Remove a directory on OneDrive - no sync will be performed.'
|
||||
complete -c onedrive -l resync -d 'Forget the last saved state, perform a full sync.'
|
||||
complete -c onedrive -l single-directory -d 'Specify a single local directory within the OneDrive root to sync.'
|
||||
complete -c onedrive -l skip-dot-files -d 'Skip dot files and folders from syncing.'
|
||||
complete -c onedrive -l skip-symlinks -d 'Skip syncing of symlinks.'
|
||||
complete -c onedrive -l source-directory -d 'Source directory to rename or move on OneDrive - no sync will be performed.'
|
||||
complete -c onedrive -n "not __fish_seen_subcommand_from --monitor; and not __fish_seen_subcommand_from -m" -l synchronize -d 'Perform a synchronization.'
|
||||
complete -c onedrive -l upload-only -d 'Only upload to OneDrive, do not sync changes from OneDrive locally'
|
||||
complete -c onedrive -s v -l verbose -d 'Print more details, useful for debugging (repeat for extra debugging).'
|
||||
complete -c onedrive -l version -d 'Print the version and exit.'
|
|
@ -239,6 +239,7 @@ final class Monitor
|
|||
while (i < length) {
|
||||
inotify_event *event = cast(inotify_event*) &buffer[i];
|
||||
string path;
|
||||
string evalPath;
|
||||
// inotify event debug
|
||||
log.vdebug("inotify event wd: ", event.wd);
|
||||
log.vdebug("inotify event mask: ", event.mask);
|
||||
|
@ -280,26 +281,38 @@ final class Monitor
|
|||
|
||||
// if the event is not to be ignored, obtain path
|
||||
path = getPath(event);
|
||||
// skip events that should be excluded based on application configuration
|
||||
if (isDir(path)) {
|
||||
// The path that needs to be checked needs to include the '/'
|
||||
// configure the skip_dir & skip skip_file comparison item
|
||||
evalPath = path.strip('.');
|
||||
|
||||
// Skip events that should be excluded based on application configuration
|
||||
// We cant use isDir or isFile as this information is missing from the inotify event itself
|
||||
// Thus this causes a segfault when attempting to query this - https://github.com/abraunegg/onedrive/issues/995
|
||||
|
||||
// Based on the 'type' of event & object type (directory or file) check that path against the 'right' user exclusions
|
||||
// Directory events should only be compared against skip_dir and file events should only be compared against skip_file
|
||||
if (event.mask & IN_ISDIR) {
|
||||
// The event in question contains IN_ISDIR event mask, thus highly likely this is an event on a directory
|
||||
// This due to if the user has specified in skip_dir an exclusive path: '/path' - that is what must be matched
|
||||
if (selectiveSync.isDirNameExcluded(path.strip('.'))) {
|
||||
if (selectiveSync.isDirNameExcluded(evalPath)) {
|
||||
// The path to evaluate matches a path that the user has configured to skip
|
||||
goto skip;
|
||||
}
|
||||
}
|
||||
if (isFile(path)) {
|
||||
// The path that needs to be checked needs to include the '/'
|
||||
} else {
|
||||
// The event in question missing the IN_ISDIR event mask, thus highly likely this is an event on a file
|
||||
// This due to if the user has specified in skip_file an exclusive path: '/path/file' - that is what must be matched
|
||||
if (selectiveSync.isFileNameExcluded(path.strip('.'))) {
|
||||
if (selectiveSync.isFileNameExcluded(evalPath)) {
|
||||
// The path to evaluate matches a file that the user has configured to skip
|
||||
goto skip;
|
||||
}
|
||||
}
|
||||
|
||||
// is the path, excluded via sync_list
|
||||
if (selectiveSync.isPathExcludedViaSyncList(path)) {
|
||||
// The path to evaluate matches a directory or file that the user has configured not to include in the sync
|
||||
goto skip;
|
||||
}
|
||||
|
||||
// handle events
|
||||
// handle the inotify events
|
||||
if (event.mask & IN_MOVED_FROM) {
|
||||
log.vdebug("event IN_MOVED_FROM: ", path);
|
||||
cookieToPath[event.cookie] = path;
|
||||
|
|
78
src/sync.d
78
src/sync.d
|
@ -1617,52 +1617,50 @@ final class SyncEngine
|
|||
} else {
|
||||
// No item ID match or folder sync match
|
||||
log.vdebug("Change does not match any criteria to apply");
|
||||
|
||||
// Before discarding change - does this ID still exist on OneDrive - as in IS this
|
||||
// potentially a --single-directory sync and the user 'moved' the file out of the 'sync-dir' to another OneDrive folder
|
||||
// This is a corner edge case - https://github.com/skilion/onedrive/issues/341
|
||||
JSONValue oneDriveMovedNotDeleted;
|
||||
try {
|
||||
oneDriveMovedNotDeleted = onedrive.getPathDetailsById(driveId, item["id"].str);
|
||||
} catch (OneDriveException e) {
|
||||
log.vdebug("oneDriveMovedNotDeleted = onedrive.getPathDetailsById(driveId, item['id'].str); generated a OneDriveException");
|
||||
if (e.httpStatusCode == 404) {
|
||||
// No .. that ID is GONE
|
||||
log.vlog("Remote change discarded - item cannot be found");
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.httpStatusCode == 429) {
|
||||
// HTTP request returned status code 429 (Too Many Requests). We need to leverage the response Retry-After HTTP header to ensure minimum delay until the throttle is removed.
|
||||
handleOneDriveThrottleRequest();
|
||||
// Retry request after delay
|
||||
log.vdebug("Retrying original request that generated the OneDrive HTTP 429 Response Code (Too Many Requests) - calling oneDriveMovedNotDeleted = onedrive.getPathDetailsById(driveId, item['id'].str);");
|
||||
try {
|
||||
oneDriveMovedNotDeleted = onedrive.getPathDetailsById(driveId, item["id"].str);
|
||||
} catch (OneDriveException e) {
|
||||
// A further error was generated
|
||||
// Rather than retry original function, retry the actual call and replicate error handling
|
||||
if (e.httpStatusCode == 404) {
|
||||
// No .. that ID is GONE
|
||||
log.vlog("Remote change discarded - item cannot be found");
|
||||
return;
|
||||
} else {
|
||||
// not a 404
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// not a 404 or a 429
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Yes .. ID is still on OneDrive but elsewhere .... #341 edge case handling
|
||||
|
||||
// What is the original local path for this ID in the database? Does it match 'syncFolderChildPath'
|
||||
if (itemdb.idInLocalDatabase(driveId, item["id"].str)){
|
||||
// item is in the database
|
||||
string originalLocalPath = itemdb.computePath(driveId, item["id"].str);
|
||||
if (canFind(originalLocalPath, syncFolderChildPath)){
|
||||
JSONValue oneDriveMovedNotDeleted;
|
||||
try {
|
||||
oneDriveMovedNotDeleted = onedrive.getPathDetailsById(driveId, item["id"].str);
|
||||
} catch (OneDriveException e) {
|
||||
log.vdebug("oneDriveMovedNotDeleted = onedrive.getPathDetailsById(driveId, item['id'].str); generated a OneDriveException");
|
||||
if (e.httpStatusCode == 404) {
|
||||
// No .. that ID is GONE
|
||||
log.vlog("Remote change discarded - item cannot be found");
|
||||
}
|
||||
if (e.httpStatusCode == 429) {
|
||||
// HTTP request returned status code 429 (Too Many Requests). We need to leverage the response Retry-After HTTP header to ensure minimum delay until the throttle is removed.
|
||||
handleOneDriveThrottleRequest();
|
||||
// Retry request after delay
|
||||
log.vdebug("Retrying original request that generated the OneDrive HTTP 429 Response Code (Too Many Requests) - calling oneDriveMovedNotDeleted = onedrive.getPathDetailsById(driveId, item['id'].str);");
|
||||
try {
|
||||
oneDriveMovedNotDeleted = onedrive.getPathDetailsById(driveId, item["id"].str);
|
||||
} catch (OneDriveException e) {
|
||||
// A further error was generated
|
||||
// Rather than retry original function, retry the actual call and replicate error handling
|
||||
if (e.httpStatusCode == 404) {
|
||||
// No .. that ID is GONE
|
||||
log.vlog("Remote change discarded - item cannot be found");
|
||||
} else {
|
||||
// not a 404
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// not a 404 or a 429
|
||||
displayOneDriveErrorMessage(e.msg);
|
||||
}
|
||||
}
|
||||
|
||||
// Yes .. ID is still on OneDrive but elsewhere .... #341 edge case handling
|
||||
// This 'change' relates to an item that WAS in 'syncFolderChildPath' but is now
|
||||
// stored elsewhere on OneDrive - outside the path we are syncing from
|
||||
// Remove this item locally as it's local path is now obsolete
|
||||
|
@ -1670,7 +1668,7 @@ final class SyncEngine
|
|||
} else {
|
||||
// out of scope for some other reason
|
||||
if (singleDirectoryScope){
|
||||
log.vlog("Remote change discarded - not in --single-directory sync scope");
|
||||
log.vlog("Remote change discarded - not in --single-directory sync scope (in DB)");
|
||||
} else {
|
||||
log.vlog("Remote change discarded - not in sync scope");
|
||||
}
|
||||
|
@ -1680,7 +1678,7 @@ final class SyncEngine
|
|||
// item is not in the database
|
||||
if (singleDirectoryScope){
|
||||
// We are syncing a single directory, so this is the reason why it is out of scope
|
||||
log.vlog("Remote change discarded - not in --single-directory sync scope");
|
||||
log.vlog("Remote change discarded - not in --single-directory sync scope (not in DB)");
|
||||
log.vdebug("Remote change discarded: ", item);
|
||||
} else {
|
||||
// Not a single directory sync
|
||||
|
|
Loading…
Reference in a new issue