diff --git a/src/commands/global_tui.cr b/src/commands/global_tui.cr index 605d318..f826873 100644 --- a/src/commands/global_tui.cr +++ b/src/commands/global_tui.cr @@ -8,18 +8,18 @@ require "../file_system_manager" module GX::Commands class GlobalTui < AbstractCommand - @file_system_manager : FileSystemManager + # @file_system_manager : FileSystemManager def initialize(@config : GX::Config) @config.load_from_env @config.load_from_file - @file_system_manager = FileSystemManager.new(@config) + # @file_system_manager = FileSystemManager.new(@config) end def execute - raise Models::InvalidFilesystemError.new("Invalid filesystem") if filesystem.nil? - @file_system_manager.mount_or_umount(filesystem) - @file_system_manager.auto_open(filesystem) if filesystem.mounted? && @config.auto_open? + # raise Models::InvalidFilesystemError.new("Invalid filesystem") if filesystem.nil? + # @file_system_manager.mount_or_umount(filesystem) + # @file_system_manager.auto_open(filesystem) if filesystem.mounted? && @config.auto_open? end def self.handles_mode diff --git a/src/commands/mapping_create.cr b/src/commands/mapping_create.cr index e03db95..6dab79e 100644 --- a/src/commands/mapping_create.cr +++ b/src/commands/mapping_create.cr @@ -36,7 +36,6 @@ module GX::Commands @config.root.try do |root| root.filesystems ||= [] of GX::Models::AbstractFilesystemConfig root.filesystems << filesystem_config - root.file_system_manager.mount_or_umount(filesystem_config) end puts "Mapping '#{create_options.name}' created and added to configuration successfully." diff --git a/src/commands/mapping_mount.cr b/src/commands/mapping_mount.cr index 51cf2b7..d94f966 100644 --- a/src/commands/mapping_mount.cr +++ b/src/commands/mapping_mount.cr @@ -8,7 +8,7 @@ require "../file_system_manager" module GX::Commands class MappingMount < AbstractCommand - @file_system_manager : FileSystemManager + # @file_system_manager : FileSystemManager def initialize(@config : GX::Config) @config.load_from_env @@ -16,14 +16,24 @@ module GX::Commands end def execute - filesystem = @config.root.try &.file_system_manager.choose_filesystem - raise Models::InvalidFilesystemError.new("Invalid filesystem") if filesystem.nil? - filesystem.mount - @file_system_manager.auto_open(filesystem) if filesystem.mounted? && @config.auto_open? + # filesystem = @config.root.try &.file_system_manager.choose_filesystem + # raise Models::InvalidFilesystemError.new("Invalid filesystem") if filesystem.nil? + # filesystem.mount + # @file_system_manager.auto_open(filesystem) if filesystem.mounted? && @config.auto_open? + end def self.handles_mode GX::Types::Mode::MappingMount end + + private def _mount_filesystem(filesystem : Models::AbstractFilesystemConfig) + raise Models::InvalidFilesystemError.new("Invalid filesystem") if filesystem.nil? + if filesystem.mounted? + Log.info { "Filesystem already mounted." } + return + end + filesystem.mount + end end end diff --git a/src/commands/mapping_umount.cr b/src/commands/mapping_umount.cr index 5e4b929..137e25a 100644 --- a/src/commands/mapping_umount.cr +++ b/src/commands/mapping_umount.cr @@ -8,21 +8,33 @@ require "../file_system_manager" module GX::Commands class MappingUmount < AbstractCommand - @file_system_manager : FileSystemManager - def initialize(@config : GX::Config) @config.load_from_env @config.load_from_file end def execute - filesystem = @config.root.try &.file_system_manager.choose_filesystem - raise Models::InvalidFilesystemError.new("Invalid filesystem") if filesystem.nil? - filesystem.umount + # root = @config.root + # raise "Missing root config" if root.nil? + + # filesystem = root.file_system_manager.choose_filesystem + # raise Models::InvalidFilesystemError.new("Invalid filesystem") if filesystem.nil? + + # filesystem.umount end def self.handles_mode GX::Types::Mode::MappingUmount end + + # OBSOLETE: + private def umount_filesystem(filesystem : Models::AbstractFilesystemConfig) + raise Models::InvalidFilesystemError.new("Invalid filesystem") if filesystem.nil? + unless filesystem.mounted? + Log.info { "Filesystem is not mounted." } + return + end + filesystem.umount + end end end diff --git a/src/file_system_manager.cr b/src/file_system_manager.cr index 088382a..e8bf6d9 100644 --- a/src/file_system_manager.cr +++ b/src/file_system_manager.cr @@ -13,25 +13,6 @@ module GX def initialize(@config : Config) end - # OBSOLETE: - # def mount_filesystem(filesystem : Models::AbstractFilesystemConfig) - # raise Models::InvalidFilesystemError.new("Invalid filesystem") if filesystem.nil? - # if filesystem.mounted? - # Log.info { "Filesystem already mounted." } - # return - # end - # filesystem.mount - # end - - # OBSOLETE: - # def umount_filesystem(filesystem : Models::AbstractFilesystemConfig) - # raise Models::InvalidFilesystemError.new("Invalid filesystem") if filesystem.nil? - # unless filesystem.mounted? - # Log.info { "Filesystem is not mounted." } - # return - # end - # filesystem.umount - # end def mount_or_umount(selected_filesystem) if !selected_filesystem.mounted?