📜 ⬆️ ⬇️

Simple OneDrive client - it's not that simple

Everyone has long been aware of Microsoft's OneDrive service, which is a cloud-based data storage with a good Web UI.

For similar services, in particular, Dropbox, a huge number of add-ons and extensions have been released, for example, MacDropAny and many others. There are not so many extensions for OneDrive, so it became a platform for us - and we released an alternative client for OneDrive - syncDriver.


')
It has all the functionality of a standard client from Microsoft, and in addition a number of features for which it makes sense to use it. You can install it here . Immediately after installation, it will prompt you to connect to the OneDrive service.

Customization


After connecting, we can configure the folder for synchronization and modes.
The modes of the first launch are separately highlighted: for example, we can download only the folder structure or nothing at all, and after initialization any changes will be downloaded.
In addition, we can configure selective synchronization filters and synchronization direction. Proxy settings are of course also supported, including authentication.

Everything, it works ...


After setup, it will take some time to download OneDrive metadata and analyze the local file system.
If your account contains a large amount of data, downloading it all takes some time. To optimize this process, you can configure selective sync.
When synchronization is complete, any changes in the folder will be reflected in your OneDrive account.

What can


If there is a need to add an arbitrary folder to OneDrive from your computer, syncDriver allows you to use symlinks - this is implemented by the Link a folder command (or the Add button on the main form).

In syncDriver, selective synchronization is possible.
The Selective Sync ... command in the settings window allows you to add / exclude a folder from synchronization: all changes made to it after that will not be sent to OneDrive.

The synchronization direction option allows you to synchronize both in one and in two directions, and you can only choose to display the changes in OneDrive to the file system without uploading back to the OneDrive cloud.

A simple way to access OneDrive is to assign a device letter to the sync folder.

In the network settings of the proxy server, you can set a username and password that a standard client cannot. This is very convenient if you use syncDriver in an organization where the Internet is distributed only through a proxy.

It works on all known Windows versions ranging from XP to 8.1, on Windows 10 we will still be testing.

How made


To support the client under different operating systems, it was decided to use .NET. Specific to different systems fragments (mainly UI and work with services / daemons) are separated into separate assemblies. The current version contains UI on Windows forms, Gtk # is used for versions for other platforms - but this version is not yet released in production.
For logging in the system, we chose NLog - it works quickly and is extremely easy to configure.
For modular SOA, we implemented our Context.NET Framework, which is available on github .

How does it work


syncDriver consists of two parts: a service and a client (UI). They communicate through json-packets sent over a network connection.
In addition, all the service settings are described in the .config file, which is configured from the client UI.
Synchronization in the client is arranged in such a way as to ensure isolation of the local file system from the file system in the cloud. Each of the file systems is implemented as a certain abstraction that solves the tasks of monitoring, indexing, and applying changes independently. This means that the OneDrive level knows nothing about the local file system and vice versa.

The whole synchronization process follows the following scenario:
- each file system conducts a full resource indexing and saves to the local database
- the file system is responsible for detecting changes and sending a message to the queue
- messages in the queue are processed in a strict order, except for special cases, which we will consider later
- in case of an error, we wait for the completion of all parallel operations and execute it again. If the error occurs again, it is recorded and issued to the UI.

The local file system monitors changes via FileSystemWatcher. In addition, there is a complete traversal of the tree at some intervals, this ensures that we will catch changes made when the client was not running.

Obtaining the OneDrive file system tree is implemented through several APIs that give us information about what has changed when compared with the local database.

A key aspect of synchronization is the fact that the synchronization process does not compare two file systems, and the file system compares it with its previous version from the database, this gives us the ability to synchronize in one direction.

Separately, renames and relocations are processed in the synchronization queue. If, for example, we created a folder with a large number of files, and then renamed it, then renaming occurs first, and all messages in the queue are renamed accordingly, that is, we load the files into the renamed or moved folder.
In case of a conflicting file change from two sides, an additional copy of the file with the suffix (1), (2), etc. is formed; automatic conflict resolution may be an option for future versions.

Problems


Most of the problems were related to the processing of events from the file system:
- when copying a large file, we get a large number of events, each of which needs to be rechecked - whether the copying process is over or not.
- when saving a file, a number of applications create a temporary file and then rename it to the destination file.
- when trying to rotate an image directly in Windows Explorer, a number of events occur: creating a new temporary file, replacing the previous one, deleting the temporary one (it differs from the previous item in that the temporary file is not renamed, but copied).

To date, most problems have been resolved, and the version is quite stable since the transition to OneDrive from SkyDrive.

What for


Our goal was to offer you an easy, stable version of the client for a well-known service from MS. Moreover, we plan to release a portable version of our product.
In parallel, we are developing a version for Linux.
But why?
Now users come to us to solve the following tasks (in order of priority):
- Work under Windows 8.1 with a local account
- Work under Windows XP
- Using symlinks
- Use of network drives
- Work through a proxy with authorization
and a number of other features.

And most of all we would like to hear in the comments which features are most interesting for you.

Source: https://habr.com/ru/post/241453/


All Articles