GithubHelp home page GithubHelp logo

cloudstash's People

Contributors

paddlesteamer avatar utkuufuk avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

5l1v3r1

cloudstash's Issues

Change FUSE StatFS

Now StatFS barely returns information about the filesystem:

func (fs *CloudStashFs) StatFS(ino int64) (*fuse.StatVFS, fuse.Status) {
log.Debug("statfs")
return &fuse.StatVFS{
NameMax: 255,
}, fuse.OK
}

It would be better if it returns total space, usage, etc.

Implement FUSE *xAttr handlers

and get rid of warnings about extended attributes on macOS. A way to do this to create another table with key-value columns and connect it to the files table with a foreign key. Or another way is to add a new xAttr column to the files table and use JSON encoding/decoding.

error handling

Go over the error messages and

  • convert critical errors to panics
  • handle the other ones appropriately
    • if a file couldn't be uploaded add it to queue
    • if there is a database error roll back everything

SIGINT handler

Cleanup in handler:

  • remove local db copy from host system
  • if removed db is different from remote storage, upload it
  • unmount fuse fs

Get rid of 'file hasn't been cached' logs

If a file is opened and then immediately flushed it's not cached but updateMetadataFromCache() is called on it. So we need to keep track of opened files and if any write operation is done on them

check database schema

In the first run, if there is a database file, check if it is a valid database (does it have all tables?)

GDrive implementation

Need implementation using drive.Drive interface. Also drive.Drive interface may change due to differences between Dropbox and GDrive APIs.

Possible problems:

  • Does google drive provide content hash like dropbox?

network rwlock

There should be rwlock in drive.Drive for network operations. For example, an upload operation shouldn't start when there is a download operation processing.

thumbnail problem

nautilus (and probably other file explorers) create thumbnails by reading contents of image files which causes the download of all files. it may be fine but also there may be a more efficient solution to this.

check remote changes of file

Implement a method that checks changes in cached files.

Ideas:

  • when a database is updated, compare it with the current database, if a file is different remove it from cache and fs (file hash is required for comparison)
  • save hash value in cache among with filename. compare it with hash value in the database. invalidate/validate cache accordingly *****

implement onedrive

There are two incomplete go libraries onedrive-go and go-onedrive so maybe implementing HTTP requests directly from API docs may be easier.
Onedrive API is very straightforward so it won't be a problem to implement limited subset of the API calls:

// Drive is the interface every remote drive client should implement
type Drive interface {
// GetProviderName returns name of the drive. i.e. dropbox
GetProviderName() string
// GetFile returns metadata and reader of the requested remote file
// If file couldn't be found, it should return common.ErrNotFound
GetFile(name string) (io.ReadCloser, error)
// PutFile uploads specified file to the remote drive
// It overwrites if the file exists
PutFile(name string, content io.Reader) error
// GetFileMetadata returns metadata of the remote file
GetFileMetadata(name string) (*Metadata, error)
// DeleteFile removes file from the remote drive
DeleteFile(name string) error
// ComputeHash computes hash of file with drive's specific method.
// This function is used as another thread, so return values should be
// printed to channels.
// r: reader of content to hash
// hchan: hash channel. computed hash should be printed to this channel
// echan: error channel. any error occurred should be printed to this channel
ComputeHash(r io.Reader, hchan chan string, echan chan error)
// GetAvailableSpace returns available space in bytes
GetAvailableSpace() (int64, error)
}

logging

The package log is very limited. Only has Print, Fatal, Panic methods and I think the usage of Fatal and Panic should be avoided.

With fmt, we get to separate stdin and stderr outputs but still, it would be nice to have more indicators on logs.

So I suggest using one of the logging libraries here. It would be nice to have debug, info, warning and error levels.

debug is for verbose messages like the ones in the fs.go:

func (r *CloudStashFs) GetAttr(ino int64, info *fuse.FileInfo) (*fuse.InoAttr, fuse.Status) {
fmt.Printf("getattr ino: %d\n", ino)

info should be used for information obviously :D. We don't have those in the code right now but I think we can use it for the messages like 'file x is uploaded to y'.

warning should be used for handled errors. For example, the error here is handled:

checksum, err := crypto.MD5Checksum(tmpfile)
if err != nil {
tmpfile.Close()
os.Remove(tmpfile.Name())
return nil, fmt.Errorf("couldn't compute md5 checksum of newly created file: %v", err)

We can log this error as a warning where it returned.

error is for fatal errors that shouldn't happen. There we can log as error and do a clean exit (unmount, wait for ongoing network operations, etc.)

Add --debug parameter

Change default log level to info and add --debug parameter for debug logs. When cloudstash is run with --debug option:

  • it should set log level of dropbox to debug
  • it should mount FUSE filesystem with -d option
  • it should set log level of logrus accordingly

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.