bcedu / VGrive

Google Drive client for linux
GNU General Public License v3.0
313 stars 33 forks source link

Select Drive folder to sync #26

Open victante opened 4 years ago

victante commented 4 years ago

Isn't it possible to select which folders of my Drive I'd like to sync? When I start the app it begin syncing everything, but I'd like to restrain it to a certain set of folders. If this feature doesn't exist, is it possible to be implemented in the future?

Tnx!

PhoneixS commented 4 years ago

I think it shouldn't be so hard to have a very basic option. For example, if we only allow specifying a root folder in Google, the only addition to the logic could be:

if (f.mimeType == "application/vnd.google-apps.folder") {
                    // It's a directory. Check if we want to download it.
                    if (f.name == root_folder) { // This if is the added piece
                        // We want to have it, create it if doesn't exist
                        // Get it's id to get its files and download them if necessary
                        if (!this.local_file_exists(current_path+"/"+f.name)) this.create_local_file(f, current_path);
                        this.check_remote_files(current_path+"/"+f.name, f.id);
                    } else {
                        this.log_message(_("INFO: %s ignored as user requests only %s").printf(current_path+"/"+f.name, root_folder), 0);
                    }
                } else if (this.is_google_mime_type (f.mimeType)) {
...

Where root_folder comes from the settings.

I don't know Vala either how to make the GUI part so it's difficult for me to develop a good patch but I can help with the logic.

Note that with the above solution the folder can't have any subfolder that isn't named as itself. The best way to do it could be to have a regex checked against the full path current_path+"/"+f.name, that would allow things like '/folder/other/*' to download all folders recursively under '/folder/other'. And maybe another option for files would be a nice addition too.

WARNING The adding elements to the library must include the condition or it will try to delete remote files that weren't synchronized. For example, check that the file is inside the root_folder before adding it to the library.

lucasmartins commented 4 years ago

A .ignore would suffice, no GUI needed.