This forum uses cookies. Click X button to hide this message. What is stored? 
Total Commander Forum Index Total Commander
Forum - Public Discussion and Support
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Google Drive Add On - creates new directories at copy

 
Post new topic   Reply to topic    Total Commander Forum Index -> TC9.0x bug reports (English) Printable version
View previous topic :: View next topic  
Author Message
dorin
Junior Member
Junior Member


Joined: 10 Jun 2017
Posts: 4
Location: italy

PostPosted: Sat Jun 10, 2017 5:47 am    Post subject: Google Drive Add On - creates new directories at copy Reply with quote

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
Back to top
View user's profile Send private message
dorin
Junior Member
Junior Member


Joined: 10 Jun 2017
Posts: 4
Location: italy

PostPosted: Sat Jun 10, 2017 6:30 am    Post subject: Hint to imlement Reply with quote

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:
   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();
   }

Back to top
View user's profile Send private message
dorin
Junior Member
Junior Member


Joined: 10 Jun 2017
Posts: 4
Location: italy

PostPosted: Sat Jun 10, 2017 7:57 am    Post subject: google drive pannel Reply with quote

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 Sun Jun 11, 2017 3:47 am; edited 1 time in total
Back to top
View user's profile Send private message
dorin
Junior Member
Junior Member


Joined: 10 Jun 2017
Posts: 4
Location: italy

PostPosted: Sun Jun 11, 2017 3:45 am    Post subject: syncronize dirs to google drive Reply with quote

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)
Back to top
View user's profile Send private message
ghisler(Author)
Site Admin
Site Admin


Joined: 04 Feb 2003
Posts: 34649
Location: Switzerland

PostPosted: Mon Jun 12, 2017 8:21 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
patrickdrd
Junior Member
Junior Member


Joined: 06 Jun 2006
Posts: 47

PostPosted: Mon Jul 03, 2017 5:52 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Total Commander Forum Index -> TC9.0x bug reports (English) All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Impressum: This site is maintained by Ghisler Software GmbH

Using phpBB © 2001-2005 phpBB Group