Compare commits
4 Commits
18edcef1c3
...
96e2845a5b
Author | SHA1 | Date | |
---|---|---|---|
96e2845a5b | |||
7c18466e95 | |||
c36204c7a8 | |||
52d0489a1b |
@ -20,7 +20,7 @@ COPY Tranga/Tranga.csproj /src/Tranga/Tranga.csproj
|
|||||||
RUN dotnet restore /src/Tranga.sln
|
RUN dotnet restore /src/Tranga.sln
|
||||||
|
|
||||||
COPY . /src/
|
COPY . /src/
|
||||||
RUN dotnet publish -c Release -o /publish -maxcpucount:1
|
RUN dotnet publish -c Release --property:OutputPath=/publish -maxcpucount:1
|
||||||
|
|
||||||
FROM base AS runtime
|
FROM base AS runtime
|
||||||
EXPOSE 6531
|
EXPOSE 6531
|
||||||
|
@ -148,7 +148,7 @@ public class JobBoss : GlobalBase
|
|||||||
Regex idRex = new (@"(.*)\.json");
|
Regex idRex = new (@"(.*)\.json");
|
||||||
|
|
||||||
//Load json-job-files
|
//Load json-job-files
|
||||||
foreach (FileInfo file in new DirectoryInfo(TrangaSettings.jobsFolderPath).EnumerateFiles().Where(fileInfo => idRex.IsMatch(fileInfo.Name)))
|
foreach (FileInfo file in new DirectoryInfo(TrangaSettings.jobsFolderPath).EnumerateFiles().Where(fileInfo => idRex.IsMatch(fileInfo.Name)))
|
||||||
{
|
{
|
||||||
Log($"Adding {file.Name}");
|
Log($"Adding {file.Name}");
|
||||||
Job? job = JsonConvert.DeserializeObject<Job>(File.ReadAllText(file.FullName),
|
Job? job = JsonConvert.DeserializeObject<Job>(File.ReadAllText(file.FullName),
|
||||||
@ -163,6 +163,7 @@ public class JobBoss : GlobalBase
|
|||||||
{
|
{
|
||||||
Log($"Adding Job {job}");
|
Log($"Adding Job {job}");
|
||||||
this.jobs.Add(job);
|
this.jobs.Add(job);
|
||||||
|
UpdateJobFile(job, file.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,42 +204,28 @@ public class JobBoss : GlobalBase
|
|||||||
internal void UpdateJobFile(Job job, string? oldFile = null)
|
internal void UpdateJobFile(Job job, string? oldFile = null)
|
||||||
{
|
{
|
||||||
string newJobFilePath = Path.Join(TrangaSettings.jobsFolderPath, $"{job.id}.json");
|
string newJobFilePath = Path.Join(TrangaSettings.jobsFolderPath, $"{job.id}.json");
|
||||||
|
string oldFilePath = Path.Join(TrangaSettings.jobsFolderPath, oldFile);
|
||||||
|
|
||||||
if (!this.jobs.Any(jjob => jjob.id == job.id))
|
if (File.Exists(oldFilePath))
|
||||||
{
|
{
|
||||||
|
Log($"Deleting Job-file {oldFilePath}");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Log($"Deleting Job-file {newJobFilePath}");
|
while(IsFileInUse(oldFilePath))
|
||||||
while(IsFileInUse(newJobFilePath))
|
|
||||||
Thread.Sleep(10);
|
Thread.Sleep(10);
|
||||||
File.Delete(newJobFilePath);
|
File.Delete(oldFilePath);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log(e.ToString());
|
Log(e.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Log($"Exporting Job {newJobFilePath}");
|
|
||||||
string jobStr = JsonConvert.SerializeObject(job, Formatting.Indented);
|
|
||||||
while(IsFileInUse(newJobFilePath))
|
|
||||||
Thread.Sleep(10);
|
|
||||||
File.WriteAllText(newJobFilePath, jobStr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(oldFile is not null)
|
Log($"Exporting Job {newJobFilePath}");
|
||||||
try
|
string jobStr = JsonConvert.SerializeObject(job, Formatting.Indented);
|
||||||
{
|
while(IsFileInUse(newJobFilePath))
|
||||||
Log($"Deleting old Job-file {oldFile}");
|
Thread.Sleep(10);
|
||||||
while(IsFileInUse(oldFile))
|
File.WriteAllText(newJobFilePath, jobStr);
|
||||||
Thread.Sleep(10);
|
|
||||||
File.Delete(oldFile);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Log(e.ToString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateAllJobFiles()
|
private void UpdateAllJobFiles()
|
||||||
|
Loading…
Reference in New Issue
Block a user