From 404fcd815c4abe00742531bf19a5224c0fe45b36 Mon Sep 17 00:00:00 2001 From: Thiago da Silva Date: Tue, 25 Mar 2014 10:03:05 -0400 Subject: Updating code to call fs_utils instead of python's os module This change is being done to prepare the code to always call fs_utils for all filesystem calls on the data being stored. By creating this interface (i.e., fs_utils), we can then make a seamless change to use the current method of 'os.' calls over FUSE _or_ libgfapi. This new method will be introduced in a new separate patch. Change-Id: Ic768fa7352d7672b1f060230bb4486f0ec228152 Signed-off-by: Thiago da Silva Reviewed-on: http://review.gluster.org/7333 Reviewed-by: Prashanth Pai Reviewed-by: Luis Pabon Tested-by: Luis Pabon --- gluster/swift/common/DiskDir.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'gluster/swift/common/DiskDir.py') diff --git a/gluster/swift/common/DiskDir.py b/gluster/swift/common/DiskDir.py index eb0b292..0a91009 100644 --- a/gluster/swift/common/DiskDir.py +++ b/gluster/swift/common/DiskDir.py @@ -16,7 +16,8 @@ import os import errno -from gluster.swift.common.fs_utils import dir_empty, mkdirs, os_path, do_chown +from gluster.swift.common.fs_utils import dir_empty, mkdirs, do_chown, \ + do_exists, do_touch from gluster.swift.common.utils import validate_account, validate_container, \ get_container_details, get_account_details, create_container_metadata, \ create_account_metadata, DEFAULT_GID, get_container_metadata, \ @@ -158,8 +159,8 @@ class DiskCommon(object): global _db_file if not _db_file: _db_file = os.path.join(Glusterfs.RUN_DIR, 'db_file.db') - if not os.path.exists(_db_file): - file(_db_file, 'w+') + if not do_exists(_db_file): + do_touch(_db_file) self.db_file = _db_file self.metadata = {} self.pending_timeout = pending_timeout or 10 @@ -173,7 +174,7 @@ class DiskCommon(object): self._dir_exists = None def _dir_exists_read_metadata(self): - self._dir_exists = os_path.exists(self.datadir) + self._dir_exists = do_exists(self.datadir) if self._dir_exists: self.metadata = _read_metadata(self.datadir) return self._dir_exists @@ -181,7 +182,7 @@ class DiskCommon(object): def is_deleted(self): # The intention of this method is to check the file system to see if # the directory actually exists. - return not os_path.exists(self.datadir) + return not do_exists(self.datadir) def empty(self): # If it does not exist, then it is empty. A value of True is @@ -464,7 +465,7 @@ class DiskDir(DiskCommon): If the container does exist, update the PUT timestamp only if it is later than the existing value. """ - if not os_path.exists(self.datadir): + if not do_exists(self.datadir): self.initialize(timestamp) else: if timestamp > self.metadata[X_PUT_TIMESTAMP]: -- cgit