Skip to content

Commit 6064546

Browse files
committed
Centralized block-size value.
1 parent cd7ea45 commit 6064546

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

gdrivefs/config/fs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CALCULATION_BLOCK_SIZE = 512

gdrivefs/gdfs/gdfuse.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import gdrivefs.gdfs.opened_file
2323
import gdrivefs.config
2424
import gdrivefs.config.changes
25+
import gdrivefs.config.fs
2526

2627
from gdrivefs.utility import utility
2728
from gdrivefs.change import get_change_manager
@@ -117,6 +118,8 @@ def __get_open_file(self, fh):
117118
def __build_stat_from_entry(self, entry):
118119
(uid, gid, pid) = fuse_get_context()
119120

121+
block_size_b = gdrivefs.config.fs.CALCULATION_BLOCK_SIZE
122+
120123
if entry.is_directory:
121124
effective_permission = int(Conf.get('default_perm_folder'),
122125
8)
@@ -149,7 +152,8 @@ def __build_stat_from_entry(self, entry):
149152
stat_result["st_mode"] = (stat.S_IFREG | effective_permission)
150153
stat_result["st_nlink"] = 1
151154

152-
stat_result["st_blocks"] = int(math.ceil(float(stat_result["st_size"]) / 512.0))
155+
stat_result["st_blocks"] = \
156+
int(math.ceil(float(stat_result["st_size"]) / block_size_b))
153157

154158
return stat_result
155159

@@ -553,7 +557,7 @@ def statfs(self, filepath):
553557
REF: http://stackoverflow.com/questions/4965355/converting-statvfs-to-percentage-free-correctly
554558
"""
555559

556-
block_size = 512
560+
block_size_b = gdrivefs.config.fs.CALCULATION_BLOCK_SIZE
557561

558562
try:
559563
account_info = AccountInfo.get_instance()

0 commit comments

Comments
 (0)