Skip to content

Commit

Permalink
Improved disk usage check (bsc#1073696)
Browse files Browse the repository at this point in the history
Check the parent directory if the target directory does not exist (yet).

- 4.0.26
  • Loading branch information
lslezak committed Jan 8, 2018
1 parent 57e539d commit 7767b09
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
7 changes: 7 additions & 0 deletions package/yast2-packager.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Jan 8 13:17:00 UTC 2018 - lslezak@suse.cz

- Improved disk usage check - check the parent directory if the
target directory does not exist (yet) (bsc#1073696)
- 4.0.26

-------------------------------------------------------------------
Mon Jan 8 09:49:09 UTC 2018 - lslezak@suse.cz

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-packager.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-packager
Version: 4.0.25
Version: 4.0.26
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
21 changes: 15 additions & 6 deletions src/modules/SlideShowCallbacks.rb
@@ -1,11 +1,14 @@
# encoding: utf-8

require "yast"
require "pathname"

# Yast namespace
module Yast
# Provides the Callbacks for SlideShow
class SlideShowCallbacksClass < Module
include Yast::Logger

def main
Yast.import "Pkg"
Yast.import "UI"
Expand Down Expand Up @@ -288,12 +291,18 @@ def DisplayStartInstall(pkg_name, pkg_location, pkg_description, pkg_size, delet
Builtins.y2debug("Skipping read-only partition %1", part)
next
end
# add slash if missing (needed for target_dir)
if part != "/" && Ops.greater_or_equal(Builtins.size(part), 1) &&
Builtins.substring(part, 0, 1) != "/"
part = Ops.add("/", part)

target_dir = File.join(Installation.destdir, part)

# handle missing directories (not existing yet or incorrect metadata),
# if the directory does not exist then go up, normally it should
# stop at Installation.destdir (but it will stop at "/" at last)
until File.exist?(target_dir)
log.warn("Directory #{target_dir} does not exist")
target_dir = Pathname.new(target_dir).parent.to_s
log.info("Checking the parent directory (#{target_dir})")
end
target_dir = Ops.add(Installation.destdir, part)

disk_available = Pkg.TargetAvailable(target_dir)
Builtins.y2debug(
"partition: %1 (%2), available: %3",
Expand All @@ -303,7 +312,7 @@ def DisplayStartInstall(pkg_name, pkg_location, pkg_description, pkg_size, delet
)
if Ops.less_than(disk_available, Ops.get(data, 2, 0))
Builtins.y2warning(
"Not enought free space in %1 (%2): available: %3, required: %4",
"Not enough free space in %1 (%2): available: %3, required: %4",
part,
target_dir,
disk_available,
Expand Down

0 comments on commit 7767b09

Please sign in to comment.