lib/imap/backup/serializer/directory.rb in imap-backup-14.4.1 vs lib/imap/backup/serializer/directory.rb in imap-backup-14.4.3
- old
+ new
@@ -6,21 +6,27 @@
module Imap; end
module Imap::Backup
class Serializer; end
+ # Ensures that serialization directories exist and have the correct permissions.
class Serializer::Directory
+ # The desired permissions for all directories that store backups
DIRECTORY_PERMISSIONS = 0o700
- attr_reader :relative
- attr_reader :path
-
+ # @param path [String] The base path of the account backup
+ # @param relative [String] The path relative from the base
+ #
+ # @return [void]
def initialize(path, relative)
@path = path
@relative = relative
end
+ # Creates the directory, if present and sets it's access permissions
+ #
+ # @return [void]
def ensure_exists
if !File.directory?(full_path)
Serializer::FolderMaker.new(
base: path, path: relative, permissions: DIRECTORY_PERMISSIONS
).run
@@ -31,9 +37,12 @@
FileUtils.chmod DIRECTORY_PERMISSIONS, full_path
end
private
+
+ attr_reader :relative
+ attr_reader :path
def full_path
containing_directory = File.join(path, relative)
File.expand_path(containing_directory)
end