gdrive-compendium

rustfoil in (almost) step-by-step way

Latest edit at 2021/04/18 (yyyy/mm/dd). May be outdated. Don’t forget to use your brain.
Typing conventions:
text for buttons you need to press, commands you need to enter in command line, etc.
<text> for the stuff you need to replace by
{button} for pressing keyboard button
[text] for optional stuff

Initial setup

  1. Get rustfoil (matching your OS/architecture) from https://github.com/DevYukine/rustfoil/releases/latest
  2. Get credentials.json for your Google account following the separate instructions here (thanks, Google, for making the process harder, sigh)
  3. Create a new directory on your hard drive (i.e. “c:\rustfoil”). Place the rustfoil executable there (unpack it from .zip if needed). Place the credentials.json there as well.
  4. Open command prompt (i.e. on Windows press {Win+R}, enter cmd, press {Enter}) and go to that directory. cd <path> is the usual command for that (i.e. cd c:\rustfoil. On Windows you may need to change the active drive first by entering it, i.e. d:{Enter}cd d:\rustfoil).
  5. Let rustfoil authenticate against Google. To do that on local machine:
    • run rustfoil executable (i.e. on Windows type rustfoil.exe)
    • copy the URL from Please direct your browser to <URL> and follow the instructions displayed there. prompt
    • open said URL in your browser and select the account with access to the drives/folders you want to index
    • if you get “This app isn’t verified” screen - press Advanced and Go to <project name from step 2> (unsafe) (i.e. Go to Quickstart (unsafe))
    • press Allow until you get You may now close this window. message

    If you run rustfoil on remote machine (i.e. over SSH):

    • add --headless flag to rustfoil invocation (i.e. rustfoil --headless)
    • copy the URL from Please direct your browser to <URL>, follow the instructions and enter the code displayed here: prompt
    • open said URL in your browser on any device you’re logged into and select the account with access to the drives/folders you want to index
    • if you get “This app isn’t verified” screen - press Advanced and Go to <project name from step 2> (unsafe) (i.e. Go to Quickstart (unsafe))
    • press Allow until you get Please copy this code, switch to your application and paste it there: message
    • copy the code from there and paste into the command prompt with rustfoil running, press {Enter}

    After you complete that, rustfoil should show [Info] Generated index successfully and create token.json file in the folder you run it from.

  6. Get the ID(s) of Google Drive folder(s) you want to index (ID being the part of URL after https://drive.google.com/drive/folders/ when you open said folder).
  7. Index your folder(s) by running rustfoil <flags> <ID1> [<ID2> <ID3> ...] (i.e. rustfoil 0ABcDE1FghIJKLm2PVA; or rusftoil 0ABcDE1FghIJKLm2PVA 1GHcDE1FghIJKLm2PVA for two folders). You should get
    / Scanned 226 files                                                                                                    5
    [Info] Generated index successfully
    

    and index.tfl file should appear in the folder with rustfoil.

If you’ve got no error messages and index.tfl file is there - you’re good to go.

Notable command line flags

flag meaning
--help list all available flags
-V show rustfoil version. Make sure to update to latest one in case you encounter any problems.
--headless allow for remote (headless) OAuth
--share-files share all indexed files to “Anyone with a link”
--tinfoil-auth create Google auth files for Tinfoil
--tinfoil-auth-path change path to where --tinfoil-auth creates files
uploading index to gdrive  
--upload-my-drive upload the generated index to personal gdrive of account you run rustfoil with
--upload-to-folder-id <id> upload the generated index to the gdrive folder with specified ID
--share-index share the uploaded index file to “Anyone with a link”
encryption  
--public-key <keyfile> encrypt index with public key. You can get one here. Store in folder with rustfoil, add --public-key public.key to invocation

Automation

Windows:

Possible keywords to google for similar effect on linux: create shell script, create cron task

Setting up Google Drive auth in Tinfoil

Use rustfoil with --tinfoil-auth flag to create the files needed to set up google auth in Tinfoil (i.e. just run rustfoil --tinfoil-auth once). By default it will create “COPY_TO_SD” folder where you run (can be altered with --tinfoil-auth-path). With the proper folder structure.
Just copy its contents to the root of your SD (the whole “switch” folder, replacing files if you’re asked to). Or go to “COPY_TO_SD\switch\tinfoil" and just copy credentials.json and gdrive.token files from there.
Then add a souce in Tinfoil’s File Browser with protocol gdrive: and empty path. It will make Tinfoil use said credentials at startup (and refresh if needed).

Sharing index from gdrive