Browse Source

Merge pull request #544 from trapexit/newest

check minfreespace on newest policy create
pull/549/head
trapexit 6 years ago
committed by GitHub
parent
commit
90e422c113
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      src/policy_newest.cpp

12
src/policy_newest.cpp

@ -17,6 +17,7 @@
#include "errno.hpp" #include "errno.hpp"
#include "fs.hpp" #include "fs.hpp"
#include "fs_exists.hpp" #include "fs_exists.hpp"
#include "fs_info.hpp"
#include "fs_path.hpp" #include "fs_path.hpp"
#include "policy.hpp" #include "policy.hpp"
#include "policy_error.hpp" #include "policy_error.hpp"
@ -36,13 +37,14 @@ namespace newest
int int
create(const Branches &branches_, create(const Branches &branches_,
const char *fusepath, const char *fusepath,
const uint64_t minfreespace,
vector<const string*> &paths) vector<const string*> &paths)
{ {
int rv; int rv;
int error; int error;
bool readonly;
time_t newest; time_t newest;
struct stat st; struct stat st;
fs::info_t info;
const Branch *branch; const Branch *branch;
const string *newestbasepath; const string *newestbasepath;
@ -59,11 +61,13 @@ namespace newest
error_and_continue(error,EROFS); error_and_continue(error,EROFS);
if(st.st_mtime < newest) if(st.st_mtime < newest)
continue; continue;
rv = fs::readonly(&branch->path,&readonly);
rv = fs::info(&branch->path,&info);
if(rv == -1) if(rv == -1)
error_and_continue(error,ENOENT); error_and_continue(error,ENOENT);
if(readonly)
if(info.readonly)
error_and_continue(error,EROFS); error_and_continue(error,EROFS);
if(info.spaceavail < minfreespace)
error_and_continue(error,ENOSPC);
newest = st.st_mtime; newest = st.st_mtime;
newestbasepath = &branch->path; newestbasepath = &branch->path;
@ -169,7 +173,7 @@ namespace mergerfs
switch(type) switch(type)
{ {
case Category::Enum::create: case Category::Enum::create:
return newest::create(branches_,fusepath,paths);
return newest::create(branches_,fusepath,minfreespace,paths);
case Category::Enum::action: case Category::Enum::action:
return newest::action(branches_,fusepath,paths); return newest::action(branches_,fusepath,paths);
case Category::Enum::search: case Category::Enum::search:

Loading…
Cancel
Save