diff --git a/.github/lock.yml b/.github/lock.yml deleted file mode 100644 index b6520675..00000000 --- a/.github/lock.yml +++ /dev/null @@ -1,38 +0,0 @@ -# Configuration for lock-threads - https://github.com/dessant/lock-threads - -# Number of days of inactivity before a closed issue or pull request is locked -daysUntilLock: 30 - -# Skip issues and pull requests created before a given timestamp. Timestamp must -# follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable -skipCreatedBefore: false - -# Issues and pull requests with these labels will not be locked. Set to `[]` to disable -exemptLabels: [] - -# Label to add before locking, such as `outdated`. Set to `false` to disable -lockLabel: false - -# Comment to post before locking. Set to `false` to disable -lockComment: > - This thread has been automatically locked since there has not been - any recent activity after it was closed. Please open a new issue for - related bugs. - -# Assign `resolved` as the reason for locking. Set to `false` to disable -setLockReason: false - -# Limit to only `issues` or `pulls` -# only: issues - -# Optionally, specify configuration settings just for `issues` or `pulls` -# issues: -# exemptLabels: -# - help-wanted -# lockLabel: outdated - -# pulls: -# daysUntilLock: 30 - -# Repository to extend settings from -# _extends: repo diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml new file mode 100644 index 00000000..32f90b6d --- /dev/null +++ b/.github/workflows/lock.yml @@ -0,0 +1,32 @@ +name: 'Lock Threads' + +on: + schedule: + - cron: '0 * * * *' + +jobs: + lock: + runs-on: ubuntu-latest + steps: + - uses: dessant/lock-threads@v2.0.3 + with: + github-token: ${{ github.token }} + issue-lock-inactive-days: '7' + issue-exclude-created-before: '' + issue-exclude-labels: '' + issue-lock-labels: '' + issue-lock-comment: > + This issue has been automatically locked since there + has not been any recent activity after it was closed. + Please open a new issue for related bugs. + issue-lock-reason: 'resolved' + pr-lock-inactive-days: '7' + pr-exclude-created-before: '' + pr-exclude-labels: '' + pr-lock-labels: '' + pr-lock-comment: > + This pull request has been automatically locked since there + has not been any recent activity after it was closed. + Please open a new issue for related bugs. + pr-lock-reason: '' + process-only: '' diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b4ffed1..57c18086 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## 2.4.12 - 2021-5-28 +### Fixed +* Fix an unhandled Error 412 when uploading modified files to OneDrive Business Accounts +* Fix 'sync_list' handling of inclusions when name is included in another folders name +* Fix that options --upload-only & --remove-source-files are ignored on an upload session restore +* Fix to add file check when adding item to database if using --upload-only --remove-source-files +* Fix application crash when SharePoint displayName is being withheld + +### Updated +* Updated Lock Bot to use GitHub Actions +* Updated documentation (various) + ## 2.4.11 - 2021-4-07 ### Fixed * Fix support for '/*' regardless of location within sync_list file diff --git a/configure b/configure index 1737b191..88a1e9f2 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for onedrive v2.4.11. +# Generated by GNU Autoconf 2.69 for onedrive v2.4.13-dev. # # Report bugs to . # @@ -579,8 +579,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='onedrive' PACKAGE_TARNAME='onedrive' -PACKAGE_VERSION='v2.4.11' -PACKAGE_STRING='onedrive v2.4.11' +PACKAGE_VERSION='v2.4.13-dev' +PACKAGE_STRING='onedrive v2.4.13-dev' PACKAGE_BUGREPORT='https://github.com/abraunegg/onedrive' PACKAGE_URL='' @@ -1219,7 +1219,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures onedrive v2.4.11 to adapt to many kinds of systems. +\`configure' configures onedrive v2.4.13-dev to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1280,7 +1280,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of onedrive v2.4.11:";; + short | recursive ) echo "Configuration of onedrive v2.4.13-dev:";; esac cat <<\_ACEOF @@ -1393,7 +1393,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -onedrive configure v2.4.11 +onedrive configure v2.4.13-dev generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1410,7 +1410,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by onedrive $as_me v2.4.11, which was +It was created by onedrive $as_me v2.4.13-dev, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2162,7 +2162,7 @@ fi -PACKAGE_DATE="April 2021" +PACKAGE_DATE="May 2021" @@ -3159,7 +3159,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by onedrive $as_me v2.4.11, which was +This file was extended by onedrive $as_me v2.4.13-dev, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -3212,7 +3212,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -onedrive config.status v2.4.11 +onedrive config.status v2.4.13-dev configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index dfb0ba04..d02092c0 100644 --- a/configure.ac +++ b/configure.ac @@ -9,7 +9,7 @@ dnl - commit the changed files (configure.ac, configure) dnl - tag the release AC_PREREQ([2.69]) -AC_INIT([onedrive],[v2.4.11], [https://github.com/abraunegg/onedrive], [onedrive]) +AC_INIT([onedrive],[v2.4.13-dev], [https://github.com/abraunegg/onedrive], [onedrive]) AC_CONFIG_SRCDIR([src/main.d]) diff --git a/contrib/gentoo/onedrive-2.4.11.ebuild b/contrib/gentoo/onedrive-2.4.12.ebuild similarity index 100% rename from contrib/gentoo/onedrive-2.4.11.ebuild rename to contrib/gentoo/onedrive-2.4.12.ebuild diff --git a/contrib/spec/onedrive.spec.in b/contrib/spec/onedrive.spec.in index 439430fa..9d0a8b2c 100644 --- a/contrib/spec/onedrive.spec.in +++ b/contrib/spec/onedrive.spec.in @@ -6,7 +6,7 @@ %endif Name: onedrive -Version: 2.4.11 +Version: 2.4.12 Release: 1%{?dist} Summary: Microsoft OneDrive Client Group: System Environment/Network diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 82177097..e4f57a21 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -1,24 +1,32 @@ # Installing from Distribution Packages or Building the OneDrive Client for Linux from source ## Installing from Distribution Packages -This project has been packaged for the following Linux distributions: +This project has been packaged for the following Linux distributions as per below. The current client release is: [![Version](https://img.shields.io/github/v/release/abraunegg/onedrive)](https://github.com/abraunegg/onedrive/releases) -| Distribution | Package Name & Package Link |  i686  | x86_64 | ARMHF | AARCH64 | Extra Details | -|---------------------------------|------------------------------------------------------------------------------|:----:|:------:|:-----:|:-------:|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Alpine Linux | [onedrive](https://pkgs.alpinelinux.org/packages?name=onedrive&branch=edge) |not_supported|supported|not_supported|supported| -| Arch Linux

Manjaro Linux | [onedrive-abraunegg](https://aur.archlinux.org/packages/onedrive-abraunegg/) |supported|supported|supported|supported| Install via: `pamac build onedrive-abraunegg` from the Arch Linux User Repository (AUR)

**Note:** If asked regarding a provider for 'd-runtime' and 'd-compiler', select 'liblphobos' and 'ldc'

**Note:** System must have at least 1GB of memory & 1GB swap space -| Debian | [onedrive](https://packages.debian.org/search?keywords=onedrive) |supported|supported|supported|supported| | -| Fedora | [onedrive](https://koji.fedoraproject.org/koji/packageinfo?packageID=26044) |supported|supported|supported|supported| | -| Gentoo | [onedrive](https://gpo.zugaina.org/net-misc/onedrive) |supported|supported|not_supported|not_supported| | -| NixOS | onedrive |not_supported|supported|not_supported|not_supported| Use package `onedrive` either by adding it to `configuration.nix` or by using the command `nix-env -iA .onedrive`. This does not install a service. To install a service, use unstable channel (will stabilize in 20.09) and add `services.onedrive.enable=true` in `configuration.nix`. You can also add a custom package using the `services.onedrive.package` option (recommended since package lags upstream). Enabling the service installs a default package too (based on the channel). You can also add multiple onedrive accounts trivially, see [documentation](https://github.com/NixOS/nixpkgs/pull/77734#issuecomment-575874225). | -| openSUSE | [onedrive](https://software.opensuse.org/package/onedrive) |supported|supported|not_supported|not_supported| | -| Slackware | [onedrive](https://slackbuilds.org/repository/14.2/network/onedrive/) |supported|supported|not_supported|not_supported| | -| Solus | [onedrive](https://dev.getsol.us/search/query/FB7PIf1jG9Z9/#R) |supported|supported|not_supported|not_supported| | -| Ubuntu | [onedrive](https://launchpad.net/~yann1ck/+archive/ubuntu/onedrive) |not_supported|supported|not_supported|not_supported| Install via the Ubuntu PPA Archive:

`sudo add-apt-repository ppa:yann1ck/onedrive`
`sudo apt-get update`
`sudo apt install onedrive`| +Only the current release version or greater is supported. #### Important Note: Distribution packages may be of an older release when compared to the latest release that is [available](https://github.com/abraunegg/onedrive/releases). If a package is out of date, please contact the package maintainer for resolution. +| Distribution | Package Name & Package Link |   PKG_Version   |  i686  | x86_64 | ARMHF | AARCH64 | Extra Details | +|---------------------------------|------------------------------------------------------------------------------|:---------------:|:----:|:------:|:-----:|:-------:|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Alpine Linux | [onedrive](https://pkgs.alpinelinux.org/packages?name=onedrive&branch=edge) |Alpine Linux Edge package|not_supported|supported|not_supported|supported | | +| Arch Linux

Manjaro Linux | [onedrive-abraunegg](https://aur.archlinux.org/packages/onedrive-abraunegg/) |AUR package|supported|supported|supported|supported | Install via: `pamac build onedrive-abraunegg` from the Arch Linux User Repository (AUR)

**Note:** If asked regarding a provider for 'd-runtime' and 'd-compiler', select 'liblphobos' and 'ldc'

**Note:** System must have at least 1GB of memory & 1GB swap space +| Debian | [onedrive](https://packages.debian.org/search?keywords=onedrive) |Debian Testing package|supported|supported|supported|supported| | +| Fedora | [onedrive](https://koji.fedoraproject.org/koji/packageinfo?packageID=26044) |Fedora Rawhide package|supported|supported|supported|supported| | +| Gentoo | [onedrive](https://gpo.zugaina.org/net-misc/onedrive) | No API Available |supported|supported|not_supported|not_supported| | +| NixOS | [onedrive](https://search.nixos.org/packages?channel=20.09&from=0&size=50&sort=relevance&query=onedrive)|nixpkgs unstable package|not_supported|supported|not_supported|not_supported| Use package `onedrive` either by adding it to `configuration.nix` or by using the command `nix-env -iA .onedrive`. This does not install a service. To install a service, use unstable channel (will stabilize in 20.09) and add `services.onedrive.enable=true` in `configuration.nix`. You can also add a custom package using the `services.onedrive.package` option (recommended since package lags upstream). Enabling the service installs a default package too (based on the channel). You can also add multiple onedrive accounts trivially, see [documentation](https://github.com/NixOS/nixpkgs/pull/77734#issuecomment-575874225). | +| openSUSE | [onedrive](https://software.opensuse.org/package/onedrive) |openSUSE Tumbleweed package|supported|supported|not_supported|not_supported| | +| Raspbian | [onedrive](https://archive.raspbian.org/raspbian/pool/main/o/onedrive/) |Raspbian Stable package|not_supported|not_supported|supported|not_supported| | +| Slackware | [onedrive](https://slackbuilds.org/repository/14.2/network/onedrive/) |SlackBuilds package|supported|supported|not_supported|not_supported| | +| Solus | [onedrive](https://dev.getsol.us/search/query/FB7PIf1jG9Z9/#R) |Solus package|supported|supported|not_supported|not_supported| | +| Ubuntu 18.04 | [onedrive](https://packages.ubuntu.com/bionic/onedrive) |Ubuntu 18.04 package|supported|supported|supported|not_supported| | +| Ubuntu 20.04 | [onedrive](https://packages.ubuntu.com/focal/onedrive) |Ubuntu 20.04 package|not_supported|supported|supported|supported| | +| Ubuntu 20.10 | [onedrive](https://packages.ubuntu.com/groovy/onedrive) |Ubuntu 20.10 package|not_supported|supported|supported|supported| | +| Ubuntu 21.04 | [onedrive](https://packages.ubuntu.com/hirsute/onedrive) |Ubuntu 21.04 package|not_supported|supported|supported|supported| | +| Ubuntu PPA | [onedrive](https://launchpad.net/~yann1ck/+archive/ubuntu/onedrive) |Ubuntu PPA package |not_supported|supported|not_supported|not_supported| Install via the Ubuntu PPA Archive:

`sudo add-apt-repository ppa:yann1ck/onedrive`
`sudo apt-get update`
`sudo apt install onedrive`| +| Void Linux | [onedrive](https://voidlinux.org/packages/) |Void Linux x86_64 package|supported|supported|not_supported|not_supported| | + #### Important information for all Ubuntu and Ubuntu based distribution users: This information is specifically for the following platforms and distributions: * Ubuntu @@ -31,8 +39,9 @@ Whilst there are [onedrive](https://packages.ubuntu.com/search?keywords=onedrive If you wish to change this situation so that you can just use 'apt install onedrive', consider becoming the Ubuntu package maintainer and contribute back to the community. -## Building from Source High Level Requirements +## Building from Source - High Level Requirements * Build environment must have at least 1GB of memory & 1GB swap space +* Install the required distribution package dependencies * [libcurl](http://curl.haxx.se/libcurl/) * [SQLite 3](https://www.sqlite.org/) >= 3.7.15 * [Digital Mars D Compiler (DMD)](http://dlang.org/download.html) or [LDC – the LLVM-based D Compiler](https://github.com/ldc-developers/ldc) @@ -50,65 +59,8 @@ curl -fsS https://dlang.org/install.sh | bash -s ldc ``` ## Distribution Package Dependencies -### Dependencies: Ubuntu 16.x - i386 / i686 (less than 1GB Memory) -**Important:** Build environment must have at least 512 of memory & 1GB swap space - -**Important:** Only use this method if you have <1GB of physical memory. - -**Note:** Peppermint 7 validated with the DMD compiler on the following i386 / i686 platform: -```text -DISTRIB_ID=Peppermint -DISTRIB_RELEASE=7 -DISTRIB_CODENAME=xenial -DISTRIB_DESCRIPTION="Peppermint 7 Seven" -``` - -First install development dependencies as per below: -```text -sudo apt install build-essential -sudo apt install libcurl4-openssl-dev -sudo apt install libsqlite3-dev -sudo apt install pkg-config -sudo apt install git -sudo apt install curl -``` -For notifications the following is also necessary: -```text -sudo apt install libnotify-dev -``` -Second, install the DMD compiler as per below: -```text -sudo wget http://master.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list -sudo apt-get update && sudo apt-get -y --allow-unauthenticated install --reinstall d-apt-keyring -sudo apt-get update && sudo apt-get install dmd-compiler dub -``` - -### Dependencies: Ubuntu 16.x - i386 / i686 / x86_64 (1GB Memory or more) -**Note:** Ubuntu 16.x validated with the DMD compiler on the following Ubuntu i386 / i686 platform: -```text -DISTRIB_ID=Ubuntu -DISTRIB_RELEASE=16.04 -DISTRIB_CODENAME=xenial -DISTRIB_DESCRIPTION="Ubuntu 16.04.6 LTS" -``` - -First install development dependencies as per below: -```text -sudo apt install build-essential -sudo apt install libcurl4-openssl-dev -sudo apt install libsqlite3-dev -sudo apt install pkg-config -sudo apt install git -sudo apt install curl -``` -For notifications the following is also necessary: -```text -sudo apt install libnotify-dev -``` -Second, install the DMD compiler as per below: -```text -curl -fsS https://dlang.org/install.sh | bash -s dmd -``` +### Dependencies: Ubuntu 16.x +Ubuntu Linux 16.04 LTS reached the end of its five-year LTS window on April 30th 2021 and is no longer supported. ### Dependencies: Ubuntu 18.x / Lubuntu 18.x / Debian 9 - i386 / i686 These dependencies are also applicable for all Ubuntu based distributions such as: @@ -183,25 +135,7 @@ sudo apt install libnotify-dev ``` ### Dependencies: CentOS 6.x / RHEL 6.x -```text -sudo yum groupinstall 'Development Tools' -sudo yum install libcurl-devel -sudo yum install sqlite-devel -curl -fsS https://dlang.org/install.sh | bash -s dmd -``` -For notifications the following is also necessary: -```text -sudo yum install libnotify-devel -``` -In addition to the above requirements, the `sqlite` version used on CentOS 6.x / RHEL 6.x needs to be upgraded. Use the following instructions to update your version of `sqlite` so that it can support this client: -```text -sudo yum -y update -sudo yum -y install epel-release wget -sudo yum -y install mock -wget https://kojipkgs.fedoraproject.org//packages/sqlite/3.7.15.2/2.fc19/src/sqlite-3.7.15.2-2.fc19.src.rpm -mock --rebuild sqlite-3.7.15.2-2.fc19.src.rpm -sudo yum -y upgrade /var/lib/mock/epel-6-`arch`/result/sqlite-* -``` +CentOS 6.x and RHEL 6.x reached End of Linfe status on November 30th 2020 and is no longer supported. ### Dependencies: Fedora < Version 18 / CentOS 7.x / RHEL 7.x ```text @@ -293,8 +227,30 @@ sudo emerge x11-libs/libnotify ### Dependencies: OpenSuSE Leap 15.0 ```text -sudo zypper addrepo --check --refresh --name "D" http://download.opensuse.org/repositories/devel:/languages:/D/openSUSE_Leap_15.0/devel:languages:D.repo -sudo zypper install git libcurl-devel sqlite3-devel D:dmd D:libphobos2-0_81 D:phobos-devel D:phobos-devel-static +sudo zypper addrepo https://download.opensuse.org/repositories/devel:languages:D/openSUSE_Leap_15.0/devel:languages:D.repo +sudo zypper refresh +sudo zypper install gcc git libcurl-devel sqlite3-devel dmd phobos-devel phobos-devel-static +``` +For notifications the following is also necessary: +```text +sudo zypper install libnotify-devel +``` + +### Dependencies: OpenSuSE Leap 15.1 +```text +sudo zypper addrepo https://download.opensuse.org/repositories/devel:languages:D/openSUSE_Leap_15.1/devel:languages:D.repo +sudo zypper refresh +sudo zypper install gcc git libcurl-devel sqlite3-devel dmd phobos-devel phobos-devel-static +``` +For notifications the following is also necessary: +```text +sudo zypper install libnotify-devel +``` + +### Dependencies: OpenSuSE Leap 15.2 +```text +sudo zypper refresh +sudo zypper install gcc git libcurl-devel sqlite3-devel dmd phobos-devel phobos-devel-static ``` For notifications the following is also necessary: ```text diff --git a/src/selective.d b/src/selective.d index 6e418264..8dc444a3 100644 --- a/src/selective.d +++ b/src/selective.d @@ -277,16 +277,45 @@ private bool isPathExcluded(string path, string[] allowedPaths) // Is path is an exact match of the allowed path? if (comm.length == path.length) { - // the given path is contained in an allowed path - if (!exclude) { - log.vdebug("Evaluation against 'sync_list' result: direct match"); - finalResult = false; - // direct match, break and go sync - break; + // we have a potential exact match + // strip any potential '/*' from the allowed path, to avoid a potential lesser common match + string strippedAllowedPath = strip(allowedPath[offset..$], "/*"); + + if (path == strippedAllowedPath) { + // we have an exact path match + log.vdebug("exact path match"); + if (!exclude) { + log.vdebug("Evaluation against 'sync_list' result: direct match"); + finalResult = false; + // direct match, break and go sync + break; + } else { + log.vdebug("Evaluation against 'sync_list' result: direct match but to be excluded"); + finalResult = true; + // do not set excludeMatched = true here, otherwise parental path also gets excluded + } } else { - log.vdebug("Evaluation against 'sync_list' result: direct match but to be excluded"); - finalResult = true; - // do not set excludeMatched = true here, otherwise parental path also gets excluded + // no exact path match, but something common does match + log.vdebug("something 'common' matches the input path"); + auto splitAllowedPaths = pathSplitter(strippedAllowedPath); + string pathToEvaluate = ""; + foreach(base; splitAllowedPaths) { + pathToEvaluate ~= base; + if (path == pathToEvaluate) { + // The input path matches what we want to evaluate against as a direct match + if (!exclude) { + log.vdebug("Evaluation against 'sync_list' result: direct match for parental path item"); + finalResult = false; + // direct match, break and go sync + break; + } else { + log.vdebug("Evaluation against 'sync_list' result: direct match for parental path item but to be excluded"); + finalResult = true; + // do not set excludeMatched = true here, otherwise parental path also gets excluded + } + } + pathToEvaluate ~= dirSeparator; + } } } diff --git a/src/sync.d b/src/sync.d index 216e7df0..fe6dba2e 100644 --- a/src/sync.d +++ b/src/sync.d @@ -445,9 +445,40 @@ final class SyncEngine // Check if there is an interrupted upload session if (session.restore()) { log.log("Continuing the upload session ..."); + string uploadSessionLocalFilePath = session.getUploadSessionLocalFilePath(); auto item = session.upload(); - saveItem(item); - } + + // is 'item' a valid JSON response and not null + if (item.type() == JSONType.object) { + // Upload did not fail, JSON response contains data + // Are we in an --upload-only & --remove-source-files scenario? + // Use actual config values as we are doing an upload session recovery + if ((cfg.getValueBool("upload_only")) && (cfg.getValueBool("remove_source_files"))) { + // Log that we are deleting a local item + log.log("Removing local file as --upload-only & --remove-source-files configured"); + // are we in a --dry-run scenario? + if (!dryRun) { + // No --dry-run ... process local file delete + if (!uploadSessionLocalFilePath.empty) { + // only perform the delete if we have a valid file path + if (exists(uploadSessionLocalFilePath)) { + // file exists + log.vdebug("Removing local file: ", uploadSessionLocalFilePath); + safeRemove(uploadSessionLocalFilePath); + } + } + } + // as file is removed, we have nothing to add to the local database + log.vdebug("Skipping adding to database as --upload-only & --remove-source-files configured"); + } else { + // save the item + saveItem(item); + } + } else { + // JSON response was not valid, upload failed + log.error("ERROR: File failed to upload. Increase logging verbosity to determine why."); + } + } initDone = true; } else { // init failure @@ -3453,7 +3484,7 @@ final class SyncEngine // HTTP request returned status code 412 - ETag does not match current item's value // Delete record from the local database - file will be uploaded as a new file writeln("skipped."); - log.vdebug("Simple Upload Replace Failed - OneDrive eTag / cTag match issue"); + log.vdebug("Simple Upload Replace Failed - OneDrive eTag / cTag match issue (Personal Account)"); log.vlog("OneDrive returned a 'HTTP 412 - Precondition Failed' - gracefully handling error. Will upload as new file."); itemdb.deleteById(item.driveId, item.id); uploadFailed = true; @@ -3496,7 +3527,7 @@ final class SyncEngine // HTTP request returned status code 412 - ETag does not match current item's value // Delete record from the local database - file will be uploaded as a new file writeln("skipped."); - log.vdebug("Simple Upload Replace Failed - OneDrive eTag / cTag match issue"); + log.vdebug("Session Upload Replace Failed - OneDrive eTag / cTag match issue (Personal Account)"); log.vlog("OneDrive returned a 'HTTP 412 - Precondition Failed' - gracefully handling error. Will upload as new file."); itemdb.deleteById(item.driveId, item.id); uploadFailed = true; @@ -3567,6 +3598,16 @@ final class SyncEngine log.fileOnly(path, " is currently checked out or locked for editing by another user."); uploadFailed = true; return; + } + if (e.httpStatusCode == 412) { + // HTTP request returned status code 412 - ETag does not match current item's value + // Delete record from the local database - file will be uploaded as a new file + writeln("skipped."); + log.vdebug("Session Upload Replace Failed - OneDrive eTag / cTag match issue (Business Account)"); + log.vlog("OneDrive returned a 'HTTP 412 - Precondition Failed' - gracefully handling error. Will upload as new file."); + itemdb.deleteById(item.driveId, item.id); + uploadFailed = true; + return; } else { // display what the error is writeln("skipped."); @@ -3755,7 +3796,7 @@ final class SyncEngine log.vlog("OneDrive returned a 'HTTP 401 - Unauthorized' - gracefully handling error"); uploadFailed = true; return response; - } + } // 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 @@ -3766,6 +3807,16 @@ final class SyncEngine log.fileOnly(path, " is currently checked out or locked for editing by another user."); uploadFailed = true; return response; + } + if (e.httpStatusCode == 412) { + // HTTP request returned status code 412 - ETag does not match current item's value + // Delete record from the local database - file will be uploaded as a new file + writeln("skipped."); + log.vdebug("Session Upload Replace Failed - OneDrive eTag / cTag match issue (Sharepoint Library)"); + log.vlog("OneDrive returned a 'HTTP 412 - Precondition Failed' - gracefully handling error. Will upload as new file."); + itemdb.deleteById(item.driveId, item.id); + uploadFailed = true; + return response; } else { // display what the error is writeln("skipped."); @@ -5328,8 +5379,9 @@ final class SyncEngine if (hasId(jsonItem)) { // Are we in a --upload-only & --remove-source-files scenario? // We do not want to add the item to the database in this situation as there is no local reference to the file post file deletion - if ((uploadOnly) && (localDeleteAfterUpload)) { - // Log that we are deleting a local item + // If the item is a directory, we need to add this to the DB, if this is a file, we dont add this, the parent path is not in DB, thus any new files in this directory are not added + if ((uploadOnly) && (localDeleteAfterUpload) && (isItemFile(jsonItem))) { + // Log that we skipping adding item to the local DB and the reason why log.vdebug("Skipping adding to database as --upload-only & --remove-source-files configured"); } else { // Takes a JSON input and formats to an item which can be used by the database @@ -5672,8 +5724,21 @@ final class SyncEngine // Add to siteSearchResults so we can display what we did find string siteSearchResultsEntry; foreach (searchResult; siteQuery["value"].array) { - siteSearchResultsEntry = " * " ~ searchResult["displayName"].str; - siteSearchResults ~= siteSearchResultsEntry; + // We can only add the displayName if it is available + if ("displayName" in searchResult) { + // Use the displayName + siteSearchResultsEntry = " * " ~ searchResult["displayName"].str; + siteSearchResults ~= siteSearchResultsEntry; + } else { + // Add, but indicate displayName unavailable, use id + if ("id" in searchResult) { + siteSearchResultsEntry = " * " ~ "Unknown displayName (Data not provided by API), Site ID: " ~ searchResult["id"].str; + siteSearchResults ~= siteSearchResultsEntry; + } else { + // displayName and id unavailable, display in debug log the entry + log.vdebug("Bad SharePoint Data for site: ", searchResult); + } + } } } } else { diff --git a/src/upload.d b/src/upload.d index 3cd12519..f49d0cc1 100644 --- a/src/upload.d +++ b/src/upload.d @@ -268,6 +268,15 @@ struct UploadSession } } + string getUploadSessionLocalFilePath() { + // return the session file path + string localPath = ""; + if ("localPath" in session){ + localPath = session["localPath"].str; + } + return localPath; + } + // save session details to temp file private void save() {