Skip to content
Open
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
9 changes: 8 additions & 1 deletion src/mergerfs.balance
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ def exclude_by_size(filepath,exclude_lt,exclude_gt):
except:
return False

def exclude_by_nlink_count(filepath):
info = os.stat(filepath)
if info.st_nlink > 1:
return True
return False

def find_a_file(src,
relpath,
Expand All @@ -112,6 +117,8 @@ def find_a_file(src,
continue
if exclude_by_size(filepath,exclude_lt,exclude_gt):
continue
if exclude_by_nlink_count(filepath):
continue
return os.path.relpath(filepath,src)
return None

Expand Down Expand Up @@ -172,7 +179,7 @@ def human_to_bytes(s):


def buildargparser():
parser = argparse.ArgumentParser(description='balance files on a mergerfs mount based on percentage drive filled')
parser = argparse.ArgumentParser(description='balance files on a mergerfs mount based on percentage drive filled. files with hardlinks won't be moved')
parser.add_argument('dir',
type=str,
help='starting directory')
Expand Down