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

Choice of the cache directory #36

Merged
merged 1 commit into from
Jun 5, 2016
Merged
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
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SRC += sdk/megabdb.cpp sdk/megaclient.cpp sdk/megacrypto.cpp
OUT = $(TARGET)
OBJ = $(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(SRC)))

.PHONY:
.PHONY: clean install


# include directories
Expand Down Expand Up @@ -45,3 +45,9 @@ $(OUT): $(OBJ)

clean:
rm -f $(OBJ) $(OUT)

install: $(OUT)
mkdir -p /usr/share/doc/MegaFuse
cp FAQ.txt LICENSE.txt README.md megafuse.conf /usr/share/doc/MegaFuse/
cp megafuse.service [email protected] /lib/systemd/system/
cp $(OUT) /usr/bin/
1 change: 1 addition & 0 deletions inc/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
std::string PASSWORD;
std::string APPKEY;
std::string MOUNTPOINT;
std::string CACHEPATH;
int fuseindex;
private:
Config();
Expand Down
4 changes: 4 additions & 0 deletions megafuse.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@
#### you can specify a mountpoint here, only absolute paths are supported.

#MOUNTPOINT = /tmp/s

#### path for the cached files; /tmp is the default, change it if your /tmp is small

CACHEPATH = /tmp
7 changes: 5 additions & 2 deletions src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bool Config::parseCommandLine(int argc, char**argv)
configFile=optarg;
cout <<"ss "<<configFile<<endl;
break;
case 'f':
case 'f':
fuseindex = optind;
return false;
break;
Expand Down Expand Up @@ -149,6 +149,7 @@ void Config::LoadConfig()
CHECK_VARIABLE(PASSWORD);
CHECK_VARIABLE(APPKEY);
CHECK_VARIABLE(MOUNTPOINT);
CHECK_VARIABLE(CACHEPATH);
else
cerr<<"Could not understand the keyword at line"<<linenum<<": "<<strbuf<<endl;
}
Expand All @@ -162,7 +163,9 @@ void Config::LoadConfig()
if(PASSWORD == "")
PASSWORD = getString("Enter your password: ",true);
while(2 != countEntriesInDir(MOUNTPOINT))
MOUNTPOINT = getString("Specify a vailid mountpoint (an empty directory): ",false);
MOUNTPOINT = getString("Specify a valid mountpoint (an empty directory): ",false);
while(0 > countEntriesInDir(CACHEPATH))
CACHEPATH = getString("Specify a valid cache path (eg: /tmp): ",false);
}

Config::Config():APPKEY("MEGASDK"),fuseindex(-1),configFile("megafuse.conf")
Expand Down
5 changes: 3 additions & 2 deletions src/file_cache_row.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

#include "file_cache_row.h"
#include "Config.h"
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
Expand All @@ -12,8 +13,8 @@

file_cache_row::file_cache_row(): td(-1),status(INVALID),size(0),available_bytes(0),n_clients(0),startOffset(0),modified(false),handle(0)
{
char filename[] = "/tmp/mega.XXXXXX";
close (mkstemp(filename));
std::string filename = Config::getInstance()->CACHEPATH + "/mega.XXXXXX";
close (mkstemp(&filename[0]));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't that be filename.c_str()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well… possibly ;-)
I did what I could with my Java knowledge and a fair bit of research+help.
Feel free to submit corrections :-)
However, this pull-request is closed, as it has been merged into MegaFuse already. So I suppose you’ll have to create another pull-request.
Cheers,

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

localname = filename;
printf("creato il file %s\n",localname.c_str());
}
Expand Down