Google Drive Add On - creates new directories at copy

Please report only one bug per message!

Moderators: Hacker, Stefan2, white, sheep

Post Reply
dorin
Junior Member
Junior Member
Posts: 4
Joined: 2017-06-10, 11:29 UTC
Location: italy

Google Drive Add On - creates new directories at copy

Post by *dorin » 2017-06-10, 11:47 UTC

Google Drive can have a directory name 10 times and 10 files with the same name in the same directories (it uses an internal ID to have an unique access index)
Total Commander mimics the Windows system of unique filename and directories
When I copied a directory from Windows to Google Drive (10.000 files) I stopped it after 100 files and started it again to see the philosophy behind connecting 2 systems. I started again the copy (F5), 2 times, and I was happy when I saw the usual question panel with Skip, Overwrite older .........
But now I see that in fact at my 3 copy commands I have 3 directories with the same name in Google Drive and inside everything is 3 times. At least the directories which are generated and copied first. The files are somewhere there, very hard to find because some of the directory structure is empty, some have files ....
So if I use backup process of 30 times F5 with Overwrite all older or Skip all, I expect a normal TC to create a good backup on Windows and impossible to use structure on Google Drive. I found that files are somewhere there, so I can use search to find them but forget about navigating inside the structure created by TC on Google Drive
I checked now and even the files are copied 3 times, no warning or question at the 3, 4, ... copy command (only at the second copy command but without effect, I found that the number of duplicated is equals with the number of copy commands)
It is a good start, but Google created a new philosophy and you need to mix the 2 systems of thinking for the next version of the plug in
Thank you
Dorin

dorin
Junior Member
Junior Member
Posts: 4
Joined: 2017-06-10, 11:29 UTC
Location: italy

Hint to imlement

Post by *dorin » 2017-06-10, 12:30 UTC

Evrika ! I remember that I had to upload tons of files into complex directories in Google Drive and the principle is like this
- keep a cache with google_id, google_path
- cut the directory name from right to left until you match with a previous created dir.
- start from here to create the missing directories
- at the final directory id copy the file
- if you are at the beginning with no directory id and path cache, create one from scratch around user destination

Here is my java main code to do this maybe it can help
Enjoy ! and Thank you for Total Commander

Code: Select all

	public String uploadFile( String file_path, String directory_start, 
			String prefix_cut, int level) {
		// get directory_start_id si google_id where to create new dir
		if( file_path == null)
			return "null_path";
		String directory_start_id = tp.get_column_nomenclator_prepared( 
				"gd_start_path2", directory_start, "name",
				"id", level + 1);
		java.io.File image_name = new java.io.File( file_path);
		String file_directory = image_name.getParent();
		String file_name = image_name.getName();
		String create_directory = file_directory.substring( prefix_cut.length());
		tp.debug_info_print(100, "uploadFile dir=" + file_directory, level);
		tp.debug_info_print(100, "uploadFile name=" + file_name, level);
		tp.debug_info_print(100, "directory_start_id=" + directory_start_id, level);
		tp.debug_info_print(100, "uploadFile create dir=" + create_directory, level);
		// search directory exists
		String directory_start_google_id = null;
		String create_directory_small = create_directory;
		List<String> create_dir_list = new ArrayList<String>();
		do{
			directory_start_google_id = tp.get_column_nomenclator_prepared( 
					"gd_directories", create_directory_small, "full_path_start",
					"id_google", level + 1);
			if( tp.notFound1.equals( directory_start_google_id)){
				java.io.File filex = new java.io.File( create_directory_small);
				create_directory_small = filex.getParent();
				create_dir_list.add( 0, filex.getName());
				tp.debug_info_print(100, "uploadFile create dir small=" + create_directory_small, level);
			}
		}while( tp.notFound1.equals( directory_start_google_id) &&
				( create_directory_small != null));
		// if not find the smallest that exists
		if( tp.notFound1.equals( directory_start_google_id)){
			directory_start_google_id = tp.get_column_nomenclator_prepared( 
					"gd_start_path2", directory_start, "name",
					"id_google", level + 1);
			tp.debug_info_print(100, "uploadFile directory_start_google_id from START " + directory_start_google_id, level);
		}
		// create directory from create_directory_small to create_directory
		tp.debug_info_print(100, "uploadFile directory_start_google_id=" + directory_start_google_id, level);
		String created_now = "";
		if( create_directory_small != null)
			created_now = create_directory_small;
		for( String dir_name : create_dir_list){
			tp.debug_info_print(100, "uploadFile create_me=" + dir_name, level);
			String id_google_parent = directory_start_google_id;
			directory_start_google_id = create_folder( dir_name, directory_start_google_id, level + 1);
			if( created_now.length() > 0)
				created_now += "\\";
			created_now += dir_name;
			int res = tp.insert_into_nom( "gd_directories", 4,
					"full_path_start",
					"id_google", 
					"id_google_parent",
					"id_start",
					created_now, 
					directory_start_google_id, 
					id_google_parent,
					directory_start_id,
					level + 1);
		}
		// upload file int create_directory id_google
		tp.debug_info_print(100, "uploadFile upload file =" + file_path, level);
		File inserted_file = uploadFile( true, image_name, directory_start_google_id);
		// salveaza id-ul in baza de date 
		return inserted_file.getId();
	}


dorin
Junior Member
Junior Member
Posts: 4
Joined: 2017-06-10, 11:29 UTC
Location: italy

google drive pannel

Post by *dorin » 2017-06-10, 13:57 UTC

On the google drive panel I have now 4 directories with the same name and whichever you choose it opens the first generated one
- you can not see the content of directories if there are 2, 3, 4 with the same name (TC will open only one of them no matter which you choose)
- workaround - rename them from Google Drive to start seeing in TC (maybe rename from TC , I did not have courage to do this, yet)
Last edited by dorin on 2017-06-11, 09:47 UTC, edited 1 time in total.

dorin
Junior Member
Junior Member
Posts: 4
Joined: 2017-06-10, 11:29 UTC
Location: italy

syncronize dirs to google drive

Post by *dorin » 2017-06-11, 09:45 UTC

At synchronize dirs to google drive (tested with 400 files in 10 dirs)
- correctly detects what is on Google Drive and not on local
- (bug) detects that no local file is on google drive and wants to copy all files again - I needed this to know what files are missing (both TC and Google fail on this - the only workaround with symbolic link toward google drive local sync dir is not an option for me, yet, maybe tomorrow)
(parameters: ignore date and no content compare)

User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 36354
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) » 2017-06-12, 14:21 UTC

Unfortunately I could not reproduce this problem so far, Google drive never created two folders with the same name here. The only way to get this is to use F7 to explicitly create a directory with the same name.
Author of Total Commander
http://www.ghisler.com

User avatar
patrickdrd
Junior Member
Junior Member
Posts: 48
Joined: 2006-06-06, 22:11 UTC

Post by *patrickdrd » 2017-07-03, 11:52 UTC

I had the same problems as dorin when trying to synchronize to google drive using tc's plugin, I cannot figure what could be causing this, I quit this approach anyway and using google drive's own application

posted here:
http://ghisler.ch/board/viewtopic.php?t=47496&highlight=synchronise+synchronize

Post Reply