• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yast / yast-storage-ng / 10941449363

19 Sep 2024 12:57PM UTC coverage: 97.766% (-0.04%) from 97.804%
10941449363

Pull #1388

github

web-flow
Merge a36b6b65f into 28fd2602a
Pull Request #1388: Some draft stuff for handling resize of partitions at the Agama proposal

130 of 143 new or added lines in 14 files covered. (90.91%)

2 existing lines in 1 file now uncovered.

24459 of 25018 relevant lines covered (97.77%)

17309.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.48
/src/lib/y2storage/proposal/space_maker_actions/shrink.rb
1
# Copyright (c) [2023] SUSE LLC
2
#
3
# All Rights Reserved.
4
#
5
# This program is free software; you can redistribute it and/or modify it
6
# under the terms of version 2 of the GNU General Public License as published
7
# by the Free Software Foundation.
8
#
9
# This program is distributed in the hope that it will be useful, but WITHOUT
10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12
# more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with this program; if not, contact SUSE LLC.
16
#
17
# To contact SUSE LLC about this file by physical or electronic mail, you may
18
# find current contact information at www.suse.com.
19

20
require "y2storage/proposal/space_maker_actions/base"
4✔
21

22
module Y2Storage
4✔
23
  module Proposal
4✔
24
    module SpaceMakerActions
4✔
25
      # Action for resizing a given partition
26
      #
27
      # @see Base
28
      class Shrink < Base
4✔
29
        # @return [DiskSize, nil]
30
        attr_accessor :min_size
4✔
31
        # @return [DiskSize, nil]
32
        attr_accessor :max_size
4✔
33
        # @return [DiskSize]
34
        attr_accessor :target_size
4✔
35

36
        def adjusted_target_size
4✔
37
          if min_size && min_size > target_size
118✔
NEW
38
            min_size
×
39
          elsif max_size && max_size < target_size
118✔
NEW
40
            max_size
×
41
          else
42
            target_size
118✔
43
          end
44
        end
45

46
        # Reduces the size of the target partition
47
        #
48
        # If possible, it reduces the size of the partition by {#shrink_size}.
49
        # Otherwise, it reduces the size as much as possible.
50
        #
51
        # This method does not take alignment into account.
52
        #
53
        # @param devicegraph [Devicegraph]
54
        # @return [Array<Integer>] always empty, resizing should not cause deletion of devices
55
        def shrink(devicegraph)
4✔
56
          partition = devicegraph.find_device(sid)
118✔
57
          shrink_partition(partition)
118✔
58
          []
118✔
59
        end
60

61
        protected
4✔
62

63
        # @param partition [Partition]
64
        def shrink_partition(partition)
4✔
65
          # Explicitly avoid alignment to keep current behavior (to be reconsidered)
66
          partition.resize(adjusted_target_size, align_type: nil)
118✔
67
        end
68
      end
69
    end
70
  end
71
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc