Sha256: d81d54c6d93b360298f60705107e92903faaef05ec39eb200ce9c1527ea82a13

Contents?: true

Size: 826 Bytes

Versions: 1

Compression:

Stored size: 826 Bytes

Contents

require "os"

require "imap/backup/serializer/folder_maker"

module Imap::Backup
  class Serializer; end

  class Serializer::Directory
    DIRECTORY_PERMISSIONS = 0o700

    attr_reader :relative
    attr_reader :path

    def initialize(path, relative)
      @path = path
      @relative = relative
    end

    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

    private

    def full_path
      containing_directory = File.join(path, relative)
      File.expand_path(containing_directory)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
imap-backup-10.0.0 lib/imap/backup/serializer/directory.rb