Skip to main content

gdrive-filesys is a Linux or macOS filesystem for Google Drive.

Project description

gdrive-filesys

gdrive-filesys is a Linux or macOS filesystem for Google Drive.

gdrive-filesys is a network filesystem that gives your computer direct access to your files on Google Drive. gdrive-filesys allows you to use files on Google Drive as if they were files on your local computer.

gdrive-filesys has been optimized to allow git repos to be stored on google drive:

gdrive-filesys mount ~/mnt
cd ~/mnt
git clone <repo>

gdrive-filesys by default performs an on-demand download of files when your computer attempts to use them.

Key features

gdrive-filesys has several nice features that make it significantly more useful than other Google Drive clients:

  • The default is to only download files when you use them. The deafult is to only download a file if you (or a program on your computer) uses that file. You don't need to wait hours for a sync client to sync your entire Google Drive account to your local computer.

  • Downloading all files from Google Drive. You can automaticaly download all files to to your local filesystem. This will ensure that all files can be accessed offline when your computer is disconnected from the internet.

  • Bidirectional sync. gdrive-filesys will only download a file when you access a file that has been changed remotely on Google Drive. If you somehow simultaneously modify a file both locally on your computer and also remotely on Google Drive, gdrive-filesys will keep the most recently modified file. The default is to check Google Drive once every minute for any remotely changed files.

  • Can be used offline. Files you've opened previously will be available even if your computer has no access to the internet. While your computer is disconnected from the internet, you can continue to update the local filesystem and when you reconnect to the internet, the locally updated files will be uploaded to google drive.

  • Fast. gdrive-filesys asynchronously performs network requests to Google Drive once every minute. gdrive-filesys caches both filesystem metadata and file contents both in memory and on-disk. Filesytem operations will always be fast unless a large file must be read from Google Drive.

  • gitignore files. Files that match a .gitignore file are only cached locally and are not uploaded to Google Drive. This means that Python virtual environment packages in .venv and nodejs packages in node_modules are only installed locally.

Local Only directories. Directories can be configued to only store files locally in your native filesystem to improve small file performance. The ~/.gdrive-filesys/config.toml file is used to configure local only directories. Thenode_modules directory is configured as a local only directory so node packages are stored locally in your native filesystem, and npm install will run very fast.

This is the default `config.toml' file:

### This is the configuration file.
### It should be placed in $HOME/.gdrive-filesys/config.toml

# Directory names that are only created localy and not synced to Google Drive.
# Files in local only directories are stored in the native filessystem for fast
# updates.  Install directories are good candidates to be stored locally.
local_only = [
   "node_modules",    
]

Quick start

Install FUSE

OSX

On Mac OSX, gdrive-filesys requires osxfuse and pkg-config:

$ brew update; brew install pkg-config; brew tap homebrew/cask; brew install --cask osxfuse

Ubuntu / Debian

On Ubuntu / Debian, gdrive-filesys requires libfuse-dev, libssl-dev and pkg-config:

sudo apt-get install -y fuse3 libfuse-dev libssl-dev pkg-config

Fedora

On Fedora, gdrive-filesys requires gcc, fuse3-devel, and pkg-config:

sudo dnf install -y gcc fuse3-devel pkg-config

Google Drive Authentication

  1. Follow these instuctions to create the required credentials.json file.
  2. Download the credentials.json file and place it in your ~/.gdrive-filesys/ directory.

Install gdrive-filesys:

MacOS

Install pipx:

brew install pipx
pipx ensurepath
sudo pipx ensurepath --global # optional to allow pipx actions with --global argument
pipx install gdrive-filesys

Ubuntu / Debian

sudo apt update
sudo apt install pipx
pipx ensurepath
sudo pipx ensurepath --global # optional to allow pipx actions with --global argument
pipx install gdrive-filesys

Fedora

sudo dnf install pipx
pipx ensurepath
sudo pipx ensurepath --global # optional to allow pipx actions with --global argument
pipx install gdrive-filesys

Mount Filesystem

Create mountpoint directory:

MOUNTPOINT=~/mnt
mkdir $MOUNTPOINT

Mount Filesystem:

gdrive-filesys mount $MOUNTPOINT # add --downloadall to sync all files

Notes:

  • It's recommended to run it as user, not as root. For this to work the mountpoint must be owned by the user.
  • The cache update interval defaults to 1 minutes, and can be set with the --updateinterval option.

Unmount Filesystem

gdrive-filesys unmount $MOUNTPOINT

or

fusermount -u $MOUNTPOINT

Display gdrive-filesys activity:

gdrive-filesys status

Building gdrive-filesys yourself

Create Virtual Environment:

cd gdrive-filesys
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -e .

Mount filesystem:

$ ./src/gdrive_filesys/cli.py $MOUNTPOINT

Running tests

The best way to test is to clone a repo, and install, build and run the application.

Mount Filesystem:

gdrive-filesys mount $MOUNTPOINT

Build and run web application:

cd $MOUNTPOINT
git clone https://github.com/allproxy/allproxy.git
npm install
npm run build
npm start

Run python application:

cd $MOUNTPOINT
git clone https://github.com/davechri/gdrive-filesys.git
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -e .
./src/gdrive_filesys/cli.py status

Troubleshooting

If the filesystem appears to hang, its possible the fileystem has crashed. To resolve this:

  • Remount: fusermount -u $MOUNTPOINT and remount gdrive-filesys mount $MOUNTPOINT
  • Clear the local cache: fusermount -u $MOUNTPOINT and remount gdrive-filesys mount $MOUNTPOINT --clearcache
  • Restart your computer

Logging

  • Error Log: error logs are logged to ~/.gdrive-filesys/error.log
  • HTTP Log: HTTP errors are logged to ~/.gdrive-filesys/http.log

Debug Logging

For debug logging use the --debug option. The --verbose option will produce more verbose logging.

gdrive-filesys mount $MOUNTPOINT --debug &> ~/path_to_my_log_file

Display gdrive-filesys status

Filesystem statistics are displayed every 10 seconds.

gdrive-filesys status
18:11:12 ONLINE:
	LOCAL_ONLY:   /home/dave/.gdrive-filesys/localonly=969.2 kB
	GITIGNORE:    dirs=0     files=0        links=2    cached=0 Bytes   total=0 Bytes
	GOOGLE_DRIVE: dirs=495   files=3109     links=5    cached=7.3 MB    total=121.1 MB
18:11:24 ONLINE:
	FILESYS OPS:  getattr=424 readdir=32 read=290 flush=249 readlink=4 
	LOCAL_ONLY:   /home/dave/.gdrive-filesys/localonly=969.2 kB
	GITIGNORE:    dirs=0     files=0        links=2    cached=0 Bytes   total=0 Bytes
	GOOGLE_DRIVE: dirs=495   files=3109     links=5    cached=7.3 MB    total=121.1 MB
18:11:36 ONLINE:
	FILESYS OPS:  getattr=311 readdir=18 read=63 flush=63 readlink=644 
	LOCAL_ONLY:   /home/dave/.gdrive-filesys/localonly=969.2 kB
	GITIGNORE:    dirs=0     files=0        links=2    cached=0 Bytes   total=0 Bytes
	GOOGLE_DRIVE: dirs=495   files=3109     links=5    cached=7.3 MB    total=121.1 MB

Dump Internal State

Display metadata:

gdrive-filesys metadata

Display directory entries:

gdrive-filesys directories

Diaplay all unread files:

gdrive-filesys unread

Display the event queue:

gdrive-filesys eventqueue

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gdrive_filesys-0.0.8.tar.gz (57.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gdrive_filesys-0.0.8-py3-none-any.whl (73.6 kB view details)

Uploaded Python 3

File details

Details for the file gdrive_filesys-0.0.8.tar.gz.

File metadata

  • Download URL: gdrive_filesys-0.0.8.tar.gz
  • Upload date:
  • Size: 57.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for gdrive_filesys-0.0.8.tar.gz
Algorithm Hash digest
SHA256 eb7324343de1de2eb53c04567533b91cf6871bde263a235295f0cfa5b1160920
MD5 959d7b767b5368c774dd1d1b10bda7ba
BLAKE2b-256 a2e71d1f52663f41e2d124271e8099997dcd25b85673d80f9f001b6c551af1ba

See more details on using hashes here.

File details

Details for the file gdrive_filesys-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: gdrive_filesys-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 73.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for gdrive_filesys-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 bb8fb804c8bc7fed12c383859722b34e5724ac83322c0a372710554e44443a22
MD5 0b7d96e2bc8a0ba5e455041061a95076
BLAKE2b-256 4a589766abe1a5d583083c84ec554c293d9bc767d745a129a0f68f9f33558c18

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page