-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved the GUI and system checks that handle uploading video data
commit-id:00ffc232
- Loading branch information
Showing
13 changed files
with
154 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,46 @@ | ||
# frozen_string_literal: true | ||
|
||
class FindExistingDisksService | ||
MOUNT_LINE = %r{\A(?<disk_name>\S+)\son\s(?:/Volumes/|)(?<name>\S+)} | ||
MOUNT_LINE = %r{\A(?<disk_name>\S+)\son\s(?:/Volumes/|)(?<name>.*)\s[(]} | ||
Device = Struct.new(:name, :disk_name) do | ||
def rdisk_name | ||
disk_name.gsub('/dev/', '/dev/r') | ||
end | ||
end | ||
|
||
class << self | ||
delegate :call, to: :new | ||
end | ||
|
||
# example line: | ||
# /dev/disk4 on /Volumes/PLANET51 (udf, local, nodev, nosuid, read-only, noowners) | ||
def call | ||
mounts = `mount` | ||
disks = [] | ||
mounts.each_line do |line| | ||
def call # rubocop:disable Metrics/MethodLength | ||
index = 0 | ||
devices.reduce(Disk.all) do |disks, device| | ||
if index.zero? | ||
disks.where( | ||
name: device.name, | ||
disk_name: [device.disk_name, device.rdisk_name] | ||
) | ||
else | ||
disks.or( | ||
Disk.where( | ||
name: device.name, | ||
disk_name: [device.disk_name, device.rdisk_name] | ||
) | ||
) | ||
end.tap { index += 1 } | ||
end | ||
end | ||
|
||
private | ||
|
||
def devices | ||
@devices ||= `mount`.each_line.filter_map do |line| | ||
next unless line.start_with?('/dev/') | ||
|
||
match = line.match(MOUNT_LINE) | ||
rdisk_name = match[:disk_name].gsub('/dev/', '/dev/r') | ||
disks << Disk.find_by(name: match[:name], disk_name: [match[:disk_name], rdisk_name]) | ||
Device.new(match[:name], match[:disk_name]) | ||
end | ||
disks.compact | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<div class="bg-processes"> | ||
<%= render ProcessComponent.new worker: ScanPlexWorker do |c| %> | ||
<%= c.with_body do %> | ||
<% if ScanPlexWorker.job.pending? %> | ||
<%= | ||
render( | ||
ProgressBarComponent.new( | ||
model: Movie, | ||
completed: (ScanPlexWorker.job.worker.completed.zero? ? 20 : ScanPlexWorker.job.worker.completed), | ||
status: :success, | ||
message: 'scanning plex for movies', | ||
show_percentage: false | ||
) | ||
) | ||
%> | ||
<% else %> | ||
<span>Done! you have a total of <%= pluralize(Video.count, 'video') %> on plex.</span> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
|
||
<%= render ProcessComponent.new worker: LoadDiskWorker do |c| %> | ||
<%= c.with_body do %> | ||
<% if LoadDiskWorker.job.pending? %> | ||
<span>Loading the disk info</span> | ||
<% elsif (disks = FindExistingDisksService.call).any? %> | ||
<span><%= disks.map(&:name).join(', ') %> is ready to be ripped.</span> | ||
<% else %> | ||
<span>No disks found</span> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<%= render ProcessComponent.new worker: UploadWorker do |c| %> | ||
<%= c.with_body do %> | ||
<% if UploadWorker.job.pending? %> | ||
|
||
<%= | ||
render( | ||
ProgressBarComponent.new( | ||
model: DiskTitle, | ||
show_percentage: false, | ||
status: :info, | ||
message: 'upload in progress' | ||
) | ||
) | ||
%> | ||
<% else %> | ||
<span>Nothing is being uploaded to <%= Config::Plex.newest.settings_ftp_host %> </span> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
class UploadWorker < ApplicationWorker | ||
option :disk_title, Types.Instance(DiskTitle) | ||
|
||
def perform | ||
progress_listener = UploadProgressListener.new( | ||
title: "Uploading #{disk_title.video.title}", | ||
file_size: disk_title.size | ||
) | ||
Ftp::UploadMkvService.call disk_title:, | ||
progress_listener: | ||
end | ||
end |