Class: Imap::Backup::Serializer::Directory
- Inherits:
-
Object
- Object
- Imap::Backup::Serializer::Directory
- Defined in:
- lib/imap/backup/serializer/directory.rb
Overview
Ensures that serialization directories exist and have the correct permissions.
Constant Summary collapse
- DIRECTORY_PERMISSIONS =
The desired permissions for all directories that store backups
0o700
Instance Method Summary collapse
-
#ensure_exists ⇒ void
Creates the directory, if present and sets it’s access permissions.
- #initialize(path, relative) ⇒ void constructor
Constructor Details
#initialize(path, relative) ⇒ void
20 21 22 23 |
# File 'lib/imap/backup/serializer/directory.rb', line 20 def initialize(path, relative) @path = path @relative = relative end |
Instance Method Details
#ensure_exists ⇒ void
This method returns an undefined value.
Creates the directory, if present and sets it’s access permissions
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/imap/backup/serializer/directory.rb', line 28 def ensure_exists if !File.directory?(full_path) Serializer::FolderMaker.new( base: path, path: relative, permissions: DIRECTORY_PERMISSIONS ).run end return if OS.windows? return if FileMode.new(filename: full_path).mode == DIRECTORY_PERMISSIONS FileUtils.chmod DIRECTORY_PERMISSIONS, full_path end |