Skip to content

Commit 5c66742

Browse files
author
reven
committed
changes made to make it run better in a unraid docker
1 parent 1f5e983 commit 5c66742

File tree

24 files changed

+333
-127
lines changed

24 files changed

+333
-127
lines changed

Client/Pages/Dashboard/Dashboard.razor

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040
<span class="label">@lblProcessingTime</span>
4141
<span class="value">@worker.ProcessingTime.ToString(@"hh\:mm\:ss")</span>
4242
</span>
43+
<span class="label-value working-file">
44+
<span class="label">@lblWorkingFile</span>
45+
<span class="value">@worker.WorkingFile</span>
46+
</span>
4347
<div class="actions-wrapper">
4448
<div class="actions">
4549
<RadzenButton Click="() => LogClicked(worker)" Text="@lblLog" />

Client/Pages/Dashboard/Dashboard.razor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public partial class Dashboard : ComponentBase, IDisposable
3131

3232
private IJSObjectReference jsFunctions;
3333

34-
private string lblLog, lblCancel, lblWaiting, lblCurrentStep, lblFile, lblOverall, lblCurrent, lblProcessingTime, lblUpcoming, lblRecentlyFinished;
34+
private string lblLog, lblCancel, lblWaiting, lblCurrentStep, lblFile, lblOverall, lblCurrent, lblProcessingTime, lblUpcoming, lblRecentlyFinished, lblWorkingFile;
3535
private Timer AutoRefreshTimer;
3636
protected override async Task OnInitializedAsync()
3737
{
@@ -49,6 +49,7 @@ protected override async Task OnInitializedAsync()
4949
lblCurrent = Translater.Instant("Pages.Dashboard.Fields.Current");
5050
lblProcessingTime = Translater.Instant("Pages.Dashboard.Fields.ProcessingTime");
5151
lblUpcoming = Translater.Instant("Pages.Dashboard.Fields.Upcoming");
52+
lblWorkingFile =Translater.Instant("Pages.Dashboard.Fields.WorkingFile");
5253
lblRecentlyFinished = Translater.Instant("Pages.Dashboard.Fields.RecentlyFinished");
5354
jsFunctions = await jSRuntime.InvokeAsync<IJSObjectReference>("import", "./scripts/Dashboard.js");
5455
await this.Refresh();

Client/Pages/Settings/Settings.razor

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,7 @@
1212

1313
<RadzenTemplateForm Data="@Model">
1414
<Fieldset Title="Pages.Settings.Labels.Directories">
15-
<InputText @bind-Value="@Model.Source" Label="Pages.Settings.Fields.Source" />
16-
<InputText @bind-Value="@Model.Destination" Label="Pages.Settings.Fields.Destination" />
17-
<InputSwitch @bind-Value="@Model.TestMode" Label="Pages.Settings.Fields.TestMode" />
18-
<InputArray @bind-Value="@Model.Extensions" Label="Pages.Settings.Fields.Extensions"
19-
EnterOnSpace="@true" />
20-
</Fieldset>
21-
<Fieldset Title="Pages.Settings.Labels.Tools">
22-
<InputText @bind-Value="@Model.HandBrakeCli" Label="Pages.Settings.Fields.HandBrakeCli" />
23-
<InputText @bind-Value="@Model.FFProbeExe" Label="Pages.Settings.Fields.FFProbeExe" />
15+
<InputFile @bind-Value="@Model.TempPath" Directory="true" Label="Pages.Settings.Fields.TempPath" />
2416
</Fieldset>
2517
</RadzenTemplateForm>
2618
</div>

Client/Pages/Settings/Settings.razor.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,20 @@ namespace FileFlow.Client.Pages
77
using FileFlow.Client.Components;
88

99
using FileFlow.Plugin;
10-
public partial class Settings : ComponentBase
10+
public partial class Settings : ComponentBase
1111
{
1212
[CascadingParameter] Blocker Blocker { get; set; }
1313

1414
private bool IsSaving { get; set; }
1515

16-
private string lblSave, lblSaving, lblSource, lblDestination;
16+
private string lblSave, lblSaving;
1717

1818
private FileFlow.Shared.Models.Settings Model { get; set; } = new FileFlow.Shared.Models.Settings();
1919

20-
private ListOption[] Containers;
21-
2220
protected override async Task OnInitializedAsync()
2321
{
2422
lblSave = Translater.Instant("Labels.Save");
2523
lblSaving = Translater.Instant("Labels.Saving");
26-
lblSource = Translater.Instant("Pages.Settings.Fields.Source");
27-
lblDestination = Translater.Instant("Pages.Settings.Fields.Destination");
28-
29-
Containers = new[] {
30-
new ListOption { Value = "mkv", Label = "MKV"},
31-
new ListOption { Value = "mp4", Label = "MP4"},
32-
};
33-
3424
Blocker.Show("Loading Settings");
3525

3626
var response = await HttpHelper.Get<FileFlow.Shared.Models.Settings>("/api/settings");

Client/wwwroot/i18n/en.json

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@
7878
"Current":"Current",
7979
"ProcessingTime":"Processing Time",
8080
"Upcoming":"Upcoming",
81-
"RecentlyFinished":"Recently Finished"
81+
"RecentlyFinished":"Recently Finished",
82+
"WorkingFile":"Working File"
8283
}
8384
},
8485
"Flow": {
@@ -123,21 +124,11 @@
123124
"Settings": {
124125
"Title": "Settings",
125126
"Labels": {
126-
"Directories": "Directories",
127-
"Tools": "Tools"
127+
"Directories": "Directories"
128128
},
129129
"Fields": {
130-
"Source": "Source Directory",
131-
"Source-Help": "The source directory containing the video files to convert. This will be recursively searched.",
132-
"Destination": "Destination Directory",
133-
"Destination-Help": "The destination directory where the encode files will be placed.\nNote: If blank, the files will be saved in the same directory as the source files and the source files will be replaced.",
134-
"Container": "Container",
135-
"Container-Placeholder": "Select container for converted videos",
136-
"Container-Help": "The container converted videos will be created with.",
137-
"TestMode": "Test Mode",
138-
"TestMode-Help": "When in test mode no actual encoding will be done, only the results of what would happen are shown.",
139-
"Extensions": "Extensions",
140-
"Extensions-Help": "A list of file extensions to be considered a video file"
130+
"TempPath": "Temp Directory",
131+
"TempPath-Help": "This directory will be used by flows to create temporary files as the flow is processed, this directory will be regularly cleaned up so keep nothing important here."
141132
}
142133
},
143134
"Tools":{

Client/wwwroot/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
import { BrotliDecode } from './scripts/decode.min.js';
4242
Blazor.start({
4343
loadBootResource: function (type, name, defaultUri, integrity) {
44-
if (type !== 'dotnetjs') {
44+
if (type !== 'dotnetjs' && location.hostname !== 'localhost') {
4545
return (async function () {
4646
const response = await fetch(defaultUri + '.br', { cache: 'no-cache' });
4747
if (!response.ok) {

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,23 @@ FROM ubuntu:20.04
44
# expose the ports we need
55
EXPOSE 5000
66

7+
# install libssl-dev, needed for the asp.net application to run
78
RUN apt-get update \
89
&& apt-get upgrade -y \
910
&& apt-get dist-upgrade -y \
1011
&& apt-get install -fy \
1112
libssl-dev
1213

14+
# install nvidia driver
15+
ENV DEBIAN_FRONTEND noninteractive
16+
RUN apt update
17+
RUN apt install software-properties-common -y
18+
RUN add-apt-repository ppa:graphics-drivers
19+
RUN apt install nvidia-driver-440 -y
20+
21+
# install ffmpeg
22+
RUN apt-get install -y ffmpeg
23+
1324
# copy the publish into the app
1425
COPY /zpublish /app
1526

Plugins/BasicNodes/BasicNodes.en.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
},
1010
"Flow":{
1111
"Parts":{
12+
"CopyFile":{
13+
"Fields":{
14+
"DestinationPath":"Destination Path",
15+
"DestinationPath-Help":"The path where the file will be copied too",
16+
"CopyFolder":"Copy Folder",
17+
"CopyFolder-Help" :"If the relative library folder structure should be copied too"
18+
}
19+
},
1220
"Log":{
1321
"Fields":{
1422
"LogType":"Type",
@@ -34,10 +42,10 @@
3442
},
3543
"MoveFile":{
3644
"Fields":{
37-
"Path":"Directory",
38-
"Path-Help":"The destination directory of the file",
39-
"FileName":"File Name",
40-
"FileName-Help":"Optional filename of the moved file, if blank the original filename will be used."
45+
"DestinationPath":"Destination Path",
46+
"DestinationPath-Help":"The path where the file will be moved too",
47+
"MoveFolder":"Copy Folder",
48+
"MoveFolder-Help" :"If the relative library folder structure should be copied too"
4149
}
4250
},
4351
"RenameFile":{
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
namespace FileFlow.BasicNodes.File
2+
{
3+
using System.ComponentModel;
4+
using FileFlow.Plugin;
5+
using FileFlow.Plugin.Attributes;
6+
7+
public class CopyFile : Node
8+
{
9+
public override int Inputs => 1;
10+
public override int Outputs => 1;
11+
public override FlowElementType Type => FlowElementType.Process;
12+
13+
[Folder(1)]
14+
public string DestinationPath { get; set; }
15+
16+
[Boolean(2)]
17+
public bool CopyFolder { get; set; }
18+
19+
private bool Canceled;
20+
21+
public override Task Cancel()
22+
{
23+
Canceled = true;
24+
return base.Cancel();
25+
}
26+
27+
28+
public override int Execute(NodeParameters args)
29+
{
30+
Canceled = false;
31+
string dest = DestinationPath;
32+
if (string.IsNullOrEmpty(dest))
33+
{
34+
args.Logger.ELog("No destination specified");
35+
args.Result = NodeResult.Failure;
36+
return -1;
37+
}
38+
args.Result = NodeResult.Failure;
39+
40+
if (CopyFolder)
41+
dest = Path.Combine(dest, args.RelativeFile);
42+
else
43+
dest = Path.Combine(dest, new FileInfo(args.FileName).Name);
44+
45+
var destDir = new FileInfo(dest).DirectoryName;
46+
if (Directory.Exists(destDir) == false)
47+
Directory.CreateDirectory(destDir);
48+
49+
// have to use file streams so we can report progress
50+
int bufferSize = 1024 * 1024;
51+
52+
using (FileStream fsOut = new FileStream(dest, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite))
53+
{
54+
using (FileStream fsIn = new FileStream(args.WorkingFile, FileMode.Open, FileAccess.Read))
55+
{
56+
try
57+
{
58+
long fileSize = fsIn.Length;
59+
fsOut.SetLength(fileSize);
60+
int bytesRead = -1;
61+
byte[] bytes = new byte[bufferSize];
62+
63+
while ((bytesRead = fsIn.Read(bytes, 0, bufferSize)) > 0 && Canceled == false)
64+
{
65+
fsOut.Write(bytes, 0, bytesRead);
66+
float percent = fsOut.Position / fileSize * 100;
67+
if (percent > 100)
68+
percent = 100;
69+
args.PartPercentageUpdate(percent);
70+
}
71+
if (Canceled == false)
72+
args.PartPercentageUpdate(100);
73+
}
74+
catch (Exception ex)
75+
{
76+
args.Logger.ELog("Failed to move file: " + ex.Message + Environment.NewLine + ex.StackTrace);
77+
return -1;
78+
}
79+
}
80+
}
81+
82+
if (Canceled)
83+
{
84+
try
85+
{
86+
System.IO.File.Delete(dest);
87+
}
88+
catch (Exception) { }
89+
args.Logger.ELog("Action was canceled.");
90+
return -1;
91+
}
92+
else
93+
{
94+
args.SetWorkingFile(dest);
95+
96+
return 0;
97+
}
98+
}
99+
}
100+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,58 @@
11
namespace FileFlow.BasicNodes.File
22
{
33
using System.ComponentModel;
4+
using System.Threading.Tasks;
45
using FileFlow.Plugin;
56
using FileFlow.Plugin.Attributes;
67

78
public class MoveFile : Node
89
{
10+
public override int Inputs => 1;
911
public override int Outputs => 1;
1012
public override FlowElementType Type => FlowElementType.Process;
13+
14+
[Folder(1)]
15+
public string DestinationPath { get; set; }
16+
17+
[Boolean(2)]
18+
public bool MoveFolder { get; set; }
19+
20+
public override int Execute(NodeParameters args)
21+
{
22+
string dest = DestinationPath;
23+
if (string.IsNullOrEmpty(dest))
24+
{
25+
args.Logger.ELog("No destination specified");
26+
args.Result = NodeResult.Failure;
27+
return -1;
28+
}
29+
args.Result = NodeResult.Failure;
30+
31+
if (MoveFolder)
32+
dest = Path.Combine(dest, args.RelativeFile);
33+
else
34+
dest = Path.Combine(dest, new FileInfo(args.FileName).Name);
35+
36+
var destDir = new FileInfo(dest).DirectoryName;
37+
if (Directory.Exists(destDir) == false)
38+
Directory.CreateDirectory(destDir);
39+
40+
long fileSize = new FileInfo(args.WorkingFile).Length;
41+
42+
Task task = Task.Run(() =>
43+
{
44+
System.IO.File.Move(args.WorkingFile, dest, true);
45+
});
46+
47+
while (task.IsCompleted == false)
48+
{
49+
long currentSize = new FileInfo(dest).Length;
50+
args.PartPercentageUpdate(currentSize / fileSize * 100);
51+
System.Threading.Thread.Sleep(50);
52+
}
53+
args.PartPercentageUpdate(100);
54+
55+
return 0;
56+
}
1157
}
1258
}

0 commit comments

Comments
 (0)