Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added starred files only support for Google Drive backend #3936

Open
wants to merge 5 commits into
base: master
from

Conversation

@jmacul2
Copy link

jmacul2 commented Feb 5, 2020

What is the purpose of this change?
Allowing start files only to display on the Google drive backend.

Was the change discussed in an issue or in the forum before?
Not that I know of....now referenced by #3928

@jmacul2 jmacul2 changed the title Added starred files only support for Google Drive backend #3928 Added starred files only support for Google Drive backend Feb 5, 2020
@@ -282,6 +282,12 @@ commands (copy, sync, etc), and with all other commands too.`,
Default: false,
Help: "Only show files that are in the trash.\nThis will show trashed files in their original directory structure.",
Advanced: true,
}, {

This comment has been minimized.

Copy link
@golangcibot

golangcibot Feb 5, 2020

File is not goimports-ed (from goimports)

Copy link
Member

ncw left a comment

Please see inline for some comments - thank you :-)

@@ -684,8 +691,16 @@ func (f *Fs) list(ctx context.Context, dirIDs []string, title string, directorie
if parentsQuery.Len() > 1 {
_, _ = parentsQuery.WriteString(" or ")
}
if f.opt.SharedWithMe && dirID == f.rootFolderID {
_, _ = parentsQuery.WriteString("sharedWithMe=true")
if dirID == f.rootFolderID {

This comment has been minimized.

Copy link
@ncw

ncw Feb 6, 2020

Member

I don't think the logic is correct here...

if dirID == f.rootFolderID and !f.opt.SharedWithMe then it should be outputing fmt.Fprintf(parentsQuery, "'%s' in parents", dirID) but in this case it outputs nothing.

I think the condition needs to be

if (f.opt.SharedWithMe || f.opt.StarredOnly) && dirID == f.rootFolderID {

This comment has been minimized.

Copy link
@jmacul2

jmacul2 Feb 6, 2020

Author

Yes, perfect. I was going to talk about this actually, but you beat me to it. This logic works for me.

}
if f.opt.StarredOnly {
if f.opt.SharedWithMe {
_, _ = parentsQuery.WriteString(" and ")

This comment has been minimized.

Copy link
@ncw

ncw Feb 6, 2020

Member

I'm not sure this and is correct without brackets - what do you think?

This comment has been minimized.

Copy link
@jmacul2

jmacul2 Feb 6, 2020

Author

It seems to work for me as is....but I'll defer to whatever seems best.

My bigger annoyance is that "starred" and "sharedwithme" seem not to play very well together. "sharedwithme" seems to retain parent/child folder structures, but starred does not. I guess it is more of how I wanted to use it. For example, I had hoped that by "staring" a specific file, it would retain its parent/child folder relationships. But I admit that would not follow how Google has it setup through its UI whereby when you star an item it only shows that item instead of its full file path.

This comment has been minimized.

Copy link
@ncw

ncw Feb 7, 2020

Member

If you want to show the starred files in their correct place then you want something like this

		if f.opt.SharedWithMe && dirID == f.rootFolderID {
			_, _ = parentsQuery.WriteString("sharedWithMe=true")
		} else {
			_, _ = fmt.Fprintf(parentsQuery, "'%s' in parents", dirID)
		}
		if f.opt.StarredOnly {
			if parentsQuery.Len() > 1 {
				_, _ = parentsQuery.WriteString(" and ")
			}
			_, _ = parentsQuery.WriteString("(mimeType='" + driveFolderType + "' or starred=true)")
		}

That will make --shared-with-me incompatible with --starred-only though as it searches in given directories only.

If you wanted starred to work with sharedwith me then you'd want something like (untested)

		if f.opt.SharedWithMe && dirID == f.rootFolderID {
			_, _ = parentsQuery.WriteString("sharedWithMe=true")
			if f.opt.StarredOnly {
				if parentsQuery.Len() > 1 {
					_, _ = parentsQuery.WriteString(" and ")
				}
				_, _ = parentsQuery.WriteString("starred=true")
			}
		} else {
			_, _ = fmt.Fprintf(parentsQuery, "'%s' in parents", dirID)
			if f.opt.StarredOnly {
				if parentsQuery.Len() > 1 {
					_, _ = parentsQuery.WriteString(" and ")
				}
				_, _ = parentsQuery.WriteString("(mimeType='" + driveFolderType + "' or starred=true)")
			}
		}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.