1

Suppose I have the following folder structure in MyDrive:

     (A)
FolderA\FolderB
FolderC

I give permission to the user email@gmail.com to FolderA and FolderC. When I give permission to the user email@gmail.com to FolderA it will be also cascaded to FolderB by Google design. The user email@gmail.com will see only FolderA and FolderC in his Shared with me folder. He will see FolderB when he'll go inside FolderA. The user sees in his Shared with me folder the following folders structure:

FolderA
FolderC

Now, if I remove email@gmail.com from FolderB and then share FolderB again with email@gmail.com he will now see in his Shared with me the following folders structure:

   (B)
FolderA
FolderB
FolderC

How I can detect those orphans like FolderB with Google Drive SDK?

pinoyyid
  • 21,499
  • 14
  • 64
  • 115
theateist
  • 13,879
  • 17
  • 69
  • 109
  • What do you mean by "orphan like FolderB"? – pinoyyid Mar 08 '17 at 21:58
  • At first the user saw in his root folder `Shared with me` just `FolderA` and `FolderC`. After my changes he sees now `FolderA`, `FolderC` and `FolderC` in his root folder `Shared with me`. So, for me `FolderB` is orphan since he should see this folder only inside `FolderA`. So, I want somehow to be able to check if a user sees `FolderB` along with `FolderA` and `FolderC` or only inside `FolderA`. – theateist Mar 08 '17 at 22:19
  • @pinoyyid, I've updated my post to describe what folders the user sees at each step. – theateist Mar 08 '17 at 22:26
  • Sure. I understand what the user sees, and to me it seems as expected. You are saying folderB is an orphan, but in what way? Have a look at the answer to http://stackoverflow.com/questions/41741520/how-do-i-search-sub-folders-and-sub-sub-folders-in-google-drive, and focus on "in Google Drive, Folders are not folders!". – pinoyyid Mar 08 '17 at 22:37
  • To answer the question, "how do I detect stuff like folderB", fetch its meta data and have a look at what's in its parents array. There may or may not be a clue there, but essentially you are asking for the history of how folderB ended up in that state and I suspect the only way is to go back through its revisions. – pinoyyid Mar 08 '17 at 22:40
  • I looked at its parents array. It's always `FolderA`, so it doesn't help me to detect stuff like `folderB`. If google drive shows folders in the structure like in my case it means that it does have TWO parents - "FolderA" and "NULL" or something that telling google drive that it should show it in root folder "Shared with me". How do I get this information. – theateist Mar 08 '17 at 22:51
  • try the "shared" and "permissions" properties. If there's nothing significant in there then I'm out of suggestions. What is your use case for needing this information? – pinoyyid Mar 08 '17 at 23:20
  • 1 - I know how to get "permissions", but how do I get "shared"? 2 - How does google drive know to show `FolderB` along with `FolderA` and `FolderC`? – theateist Mar 09 '17 at 00:12
  • shared is a boolean property of the file/folder. See https://developers.google.com/drive/v3/reference/files – pinoyyid Mar 09 '17 at 00:38
  • What about my second question? Regarding the "shared", how the boolean will help me? – theateist Mar 09 '17 at 01:03
  • 1
    my last thought on this is get the meta data of folderB at point A (see my edit to your question) using files.get:fields=* and then do it again at point B. Then compare the two sets of meta data. Either there is a difference you can use or there isn't. – pinoyyid Mar 09 '17 at 08:19
  • @pinoyyid, but how does the google drive itself distinguish these two cases? It's obviously it can distinguish between them otherwise I wouldn't see `FolderB`. – theateist Mar 09 '17 at 13:24
  • @pinoyyid, can you please tell me how does the google drive itself distinguish these two cases then? – theateist Apr 04 '17 at 16:37

0 Answers0