Skip to content

Commit

Permalink
Fix off-by-one in tootctl media commands (mastodon#30306)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire authored and noellabo committed Jun 27, 2024
1 parent f220f2c commit b9dd689
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/mastodon/media_cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def remove_orphans

model_name = path_segments.first.classify
attachment_name = path_segments[1].singularize
record_id = path_segments[2..-2].join.to_i
record_id = path_segments[2...-2].join.to_i
file_name = path_segments.last
record = record_map.dig(model_name, record_id)
attachment = record&.public_send(attachment_name)
Expand Down Expand Up @@ -147,7 +147,7 @@ def remove_orphans
end

model_name = path_segments.first.classify
record_id = path_segments[2..-2].join.to_i
record_id = path_segments[2...-2].join.to_i
attachment_name = path_segments[1].singularize
file_name = path_segments.last

Expand Down Expand Up @@ -324,7 +324,7 @@ def lookup(url)
end

model_name = path_segments.first.classify
record_id = path_segments[2..-2].join.to_i
record_id = path_segments[2...-2].join.to_i

unless PRELOAD_MODEL_WHITELIST.include?(model_name)
say("Cannot find corresponding model: #{model_name}", :red)
Expand Down Expand Up @@ -374,7 +374,7 @@ def preload_records_from_mixed_objects(objects)
next unless [7, 10].include?(segments.size)

model_name = segments.first.classify
record_id = segments[2..-2].join.to_i
record_id = segments[2...-2].join.to_i

next unless PRELOAD_MODEL_WHITELIST.include?(model_name)

Expand Down

0 comments on commit b9dd689

Please sign in to comment.