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

Some updates #104

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
339 changes: 339 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion LICENSE.txt

This file was deleted.

12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ OBJ = $(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(SRC)))


# include directories
INCLUDES = -I inc -I /usr/include/cryptopp -I sdk
INCLUDES = -I inc -I /usr/include/cryptopp -I /usr/include/cryptlib -I sdk

# C compiler flags (-g -O2 -Wall)
CCFLAGS = -O0 -g -fstack-protector-all -Wall #-non-call-exceptions
# C compiler flags (-g -Os)
CCFLAGS = -g -Os -s -march=native -pipe -fstack-protector-all -Wall #-non-call-exceptions
CCFLAGS += $(shell pkg-config --cflags libcurl fuse)
CPPFLAGS = -std=c++0x $(CCFLAGS) -D_GLIBCXX_DEBUG
CCFLAGS += -D_FILE_OFFSET_BITS=64
CPPFLAGS = -std=c++0x $(CCFLAGS) -D_GLIBCXX_DEBUG


# compiler
CC = gcc
Expand All @@ -29,7 +31,7 @@ CXX= g++
LIBS =

# compile flags
LDFLAGS = -lcryptopp -lfreeimage -ldb_cxx
LDFLAGS = -g -Os -s -march=native -pipe -lcryptopp -lfreeimage -ldb_cxx
LDFLAGS += $(shell pkg-config --libs libcurl fuse)

megafuse: $(OUT)
Expand Down
50 changes: 29 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
MegaFuse
========

This is a linux client for the MEGA cloud storage provider.
This is a linux client for the MEGA cloud storage provider, originally developed by Matteo Serva, based on an **outdated** version of Mega SDK. I've created this fork in order to maintain the project, as I'm more active, altrough I'm not a C++ expert, I'll accept pull requests and test them before pushing.

It is based on FUSE and it allows to mount the remote cloud drive on the local filesystem.
Once mounted, all linux program will see the cloud drive as a normal folder.

Expand All @@ -11,40 +12,42 @@ The files are downloaded on the fly when requested and then cached to speedup pr
The downloader will assign a higher priority to the requested chunk, and prefetch the remaining data.
This allows also fast streaming of video files without prior encoding.


please edit your config file "megafuse.conf" before running, you have to change at least your username and password.
Please edit your config file "megafuse.conf" before running, you have to change at least your username and password.
The mountpoint must be an empty directory.
By default on debian system you need to be root to mount a fuse filesystem.
Optionally you can add this tool to /etc/fstab but this is untested,yet.
Optionally you can add this tool to /etc/fstab but this is untested, yet.

to run,just
## Getting started

make
./MegaFuse
* The preferred way to get started is using my Alpine-based [Docker image](https://github.com/Amitie10g/docker-megafuse), that uses this repo.

to compile on debian or ubuntu you need these additional packages:

apt-get install libcrypto++-dev libcurl4-openssl-dev libdb5.3++-dev libfreeimage-dev libreadline-dev libfuse-dev
* Otherwise, you may build under your distro

you can pass additional options to the fuse module via the command line option -f. example:
./MegaFuse -f -o allow_other -o uid=1000
make

* To compile on debian or ubuntu you need these additional packages:

you can specify the location of the conf file with the command line option -c, by default the program will search the file "megafuse.conf" in the current path
apt install make g++ pkg-config libcrypto++-dev libcurl4-openssl-dev libdb5.3++-dev libfreeimage-dev libreadline-dev libfuse-dev

* To compile on Fedora you need these additional packages:

dnf install cryptlib-devel readline-devel cryptopp-devel freeimage-devel db4-devel curl-devel libdb-cxx-devel

* Edit ``megafuse.conf`` to add your user, password and [API key](https://www.programmableweb.com/api/mega). Then, specify the config file when running:

./MegaFuse -c /home/user/megafuse.conf
./MegaFuse -c megafuse.conf

* You can pass additional options to the fuse module via the command line option -f. example:

./MegaFuse -c megafuse.conf -f -o allow_other -o uid=1000

for the full list of options, launch the program with the option -h
* For the full list of options, launch the program with the option -h

after an abnormal termination you might need to clear the mountpoint:
* After an abnormal termination you might need to clear the mountpoint:

$ fusermount -u $MOUNTPOINT
or # umount $MOUNTPOINT

I'm currently accepting donations via paypal at the address of my main project

http://ygopro.it/web/modules.php?name=Donations&op=make

FAQ
========
Q: Is this a sync application?
Expand All @@ -70,3 +73,8 @@ FAQ
-
Q: How do I access a shared file from another account?
A: Import the file into your account, then it will be available from MegaFuse

Caveats
========

This project is based on older versions of Mega SDK, as the upstream project has been inactive several years ago. I have another branch for attempting building a similar application using newer versions of the Mega SDK.
4 changes: 2 additions & 2 deletions src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ Config* Config::getInstance()
void Config::check_variable(int &var,std::string value,std::string name)
{
var=stoi(value);
printf("caricata la variabile %s con il valore %d\n",name.c_str(),var);
printf("loaded the variable %s with the value %d\n",name.c_str(),var);

}

void Config::check_variable(std::string &var,std::string value,std::string name)
{
var = value;
printf("caricata la variabile %s con il valore %s\n",name.c_str(),value.c_str());
printf("loaded the variable %s with the value %s\n",name.c_str(),value.c_str());


}
Expand Down
3 changes: 1 addition & 2 deletions src/MegaFuse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*
*/


#include "megaclient.h"
#include "megafusemodel.h"
#include "Config.h"
Expand All @@ -26,7 +25,7 @@ MegaFuse::MegaFuse():running(true)

std::thread maintenance_loop(maintenance,this);
maintenance_loop.detach();
printf("MegaFushe::MegaFuse. Constructor finished.\n");
printf("MegaFuse::MegaFuse. Constructor finished.\n");
}
void MegaFuse::maintenance(MegaFuse* that)
{
Expand Down
3 changes: 2 additions & 1 deletion src/file_cache_row.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <cmath>

#include <megaclient.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -69,7 +70,7 @@ int CacheManager::numChunks(size_t pos)
end +=i*ChunkedHash::SEGSIZE;
if(end >= pos) return i;
}
return 8 + ceil(float(pos-end)/(8.0*ChunkedHash::SEGSIZE));
return 8 + std::ceil(float(pos-end)/(8.0*ChunkedHash::SEGSIZE));


}
Expand Down