29 lines
770 B
Crystal
29 lines
770 B
Crystal
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
#
|
|
# SPDX-FileCopyrightText: 2023 Glenn Y. Rolland <glenux@glenux.net>
|
|
# Copyright © 2023 Glenn Y. Rolland <glenux@glenux.net>
|
|
|
|
module GX::Models::Concerns
|
|
module MountWrapper
|
|
def _mount_wrapper(&block) : Nil
|
|
mount_point_safe = mount_point
|
|
return if mount_point_safe.nil?
|
|
|
|
Dir.mkdir_p(mount_point_safe) unless Dir.exists?(mount_point_safe)
|
|
if mounted?
|
|
puts "Already mounted. Skipping.".colorize(:yellow)
|
|
return
|
|
end
|
|
|
|
result_status = yield
|
|
|
|
if result_status.success?
|
|
puts "Models #{name} is now available on #{mount_point_safe}".colorize(:green)
|
|
else
|
|
puts "Error mounting the vault".colorize(:red)
|
|
return
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|