Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
69285cac1c | |||
2b13c8c198 |
@ -44,7 +44,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CliWrap" Version="3.8.2" />
|
<PackageReference Include="CliWrap" Version="3.8.2" />
|
||||||
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler" Version="8.0.12" />
|
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler" Version="9.0.10" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
|
||||||
|
@ -7,7 +7,6 @@ namespace View_by_Distance.Rename.Models;
|
|||||||
|
|
||||||
public record RenameSettings(string Company,
|
public record RenameSettings(string Company,
|
||||||
string DefaultMaker,
|
string DefaultMaker,
|
||||||
Dictionary<string, string?> DirectoryDictionary,
|
|
||||||
string? FirstPassFile,
|
string? FirstPassFile,
|
||||||
bool ForceNewId,
|
bool ForceNewId,
|
||||||
bool InPlace,
|
bool InPlace,
|
||||||
|
@ -273,7 +273,6 @@ public partial class Rename : IRename, IDisposable
|
|||||||
{
|
{
|
||||||
List<FirstPass> results = [];
|
List<FirstPass> results = [];
|
||||||
int index = -1;
|
int index = -1;
|
||||||
TimeSpan timeSpan;
|
|
||||||
foreach (KeyValuePair<string, List<FileHolder>> keyValuePair in keyValuePairs)
|
foreach (KeyValuePair<string, List<FileHolder>> keyValuePair in keyValuePairs)
|
||||||
{
|
{
|
||||||
index += 1;
|
index += 1;
|
||||||
@ -287,9 +286,6 @@ public partial class Rename : IRename, IDisposable
|
|||||||
if (keyValuePair.Value.Count > 2)
|
if (keyValuePair.Value.Count > 2)
|
||||||
throw new NotSupportedException("Too many sidecar files!");
|
throw new NotSupportedException("Too many sidecar files!");
|
||||||
SetFirstPassCollection(logger, appSettings, rename, ids, metadata, index, keyValuePair, results);
|
SetFirstPassCollection(logger, appSettings, rename, ids, metadata, index, keyValuePair, results);
|
||||||
timeSpan = new(DateTime.Now.Ticks - rename.Ticks);
|
|
||||||
if (timeSpan.TotalMilliseconds > appSettings.RenameSettings.MaxMilliSecondsPerCall)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
@ -643,7 +639,6 @@ public partial class Rename : IRename, IDisposable
|
|||||||
{
|
{
|
||||||
if (record.ExifDirectory.FilePath.FullName[..2] != directoryInfo.FullName[..2])
|
if (record.ExifDirectory.FilePath.FullName[..2] != directoryInfo.FullName[..2])
|
||||||
isWrongYear = null;
|
isWrongYear = null;
|
||||||
string directoryName;
|
|
||||||
string tfw = GetTFW(record, isWrongYear);
|
string tfw = GetTFW(record, isWrongYear);
|
||||||
string? maker = IMetaBase.GetMaker(record.ExifDirectory);
|
string? maker = IMetaBase.GetMaker(record.ExifDirectory);
|
||||||
string rootDirectory = appSettings.ResultSettings.RootDirectory;
|
string rootDirectory = appSettings.ResultSettings.RootDirectory;
|
||||||
@ -652,14 +647,7 @@ public partial class Rename : IRename, IDisposable
|
|||||||
string? splat = checkDirectoryName.Length > 3 && checkDirectoryName[^3..][1] == '!' ? checkDirectoryName[^3..] : null;
|
string? splat = checkDirectoryName.Length > 3 && checkDirectoryName[^3..][1] == '!' ? checkDirectoryName[^3..] : null;
|
||||||
string contains = record.ExifDirectory.FilePath.Id is null || ids.Contains(record.ExifDirectory.FilePath.Id.Value) ? "_ Exists _" : "_ New-Destination _";
|
string contains = record.ExifDirectory.FilePath.Id is null || ids.Contains(record.ExifDirectory.FilePath.Id.Value) ? "_ Exists _" : "_ New-Destination _";
|
||||||
string makerSplit = string.IsNullOrEmpty(maker) ? string.IsNullOrEmpty(appSettings.RenameSettings.DefaultMaker) ? string.Empty : appSettings.RenameSettings.DefaultMaker : $" {maker.Split(' ')[0]}";
|
string makerSplit = string.IsNullOrEmpty(maker) ? string.IsNullOrEmpty(appSettings.RenameSettings.DefaultMaker) ? string.Empty : appSettings.RenameSettings.DefaultMaker : $" {maker.Split(' ')[0]}";
|
||||||
if (!string.IsNullOrEmpty(splat) || isWrongYear is null || isWrongYear.Value || appSettings.RenameSettings.DirectoryDictionary.Count < 2)
|
string directoryName = GetDirectoryName(year, tfw, segments[0], splat, seasonValue, seasonName, makerSplit);
|
||||||
directoryName = GetDirectoryName(year, tfw, segments[0], splat, seasonValue, seasonName, makerSplit);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
directoryName = record.DateTime.ToString("yyyy-MM-dd");
|
|
||||||
if (appSettings.RenameSettings.DirectoryDictionary.TryGetValue(directoryName, out string? value) && !string.IsNullOrEmpty(value))
|
|
||||||
directoryName = value;
|
|
||||||
}
|
|
||||||
result = Path.GetFullPath(Path.Combine(rootDirectory, contains, directoryName));
|
result = Path.GetFullPath(Path.Combine(rootDirectory, contains, directoryName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
Scripts/lsblk.ts
Normal file
8
Scripts/lsblk.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
fetch('https://html.affirm.duckdns.org/lsblk.json')
|
||||||
|
.then((res:any) => res.text())
|
||||||
|
.then((text:any) => {
|
||||||
|
const data = JSON.parse(text);
|
||||||
|
console.log(data);
|
||||||
|
})
|
||||||
|
.catch((e:any) => console.error(e));
|
115
Scripts/podman.ts
Normal file
115
Scripts/podman.ts
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
const server = 'jmlc';
|
||||||
|
let debug: Array<string> = [];
|
||||||
|
let warning: Array<string> = [];
|
||||||
|
let volumes: Array<string> = [];
|
||||||
|
let volumeExportLines: Array<string> = [];
|
||||||
|
const pathA = 'L:/Git/AA/.vscode/helper/podman.txt';
|
||||||
|
|
||||||
|
await fetch(`https://html.${server}.duckdns.org/root.txt`)
|
||||||
|
.then((res: any) => res.text())
|
||||||
|
.then((text: any) => {
|
||||||
|
const lines = text.trim().split('\n');
|
||||||
|
for (let index = 0; index < lines.length; index++) {
|
||||||
|
const element = lines[index];
|
||||||
|
if (element == undefined || element.length === 0 || element[0] === '#' || !element.includes('podman volume export')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
volumeExportLines.push(`${server}: root: ${element}`);
|
||||||
|
debug.push(`${server}: volume [${element}] is exported.`);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((e: any) => console.error(e));
|
||||||
|
|
||||||
|
await fetch(`https://html.${server}.duckdns.org/podman.txt`)
|
||||||
|
.then((res: any) => res.text())
|
||||||
|
.then((text: any) => {
|
||||||
|
const lines = text.trim().split('\n');
|
||||||
|
for (let index = 0; index < lines.length; index++) {
|
||||||
|
const element = lines[index];
|
||||||
|
if (element == undefined || element.length === 0 || element[0] === '#' || !element.includes('podman volume export')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
volumeExportLines.push(`${server}: podman: ${element}`);
|
||||||
|
debug.push(`${server}: volume [${element}] is exported.`);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((e: any) => console.error(e));
|
||||||
|
|
||||||
|
await fetch(`https://html.${server}.duckdns.org/images-dangling-false.jsonl`)
|
||||||
|
.then((res: any) => res.text())
|
||||||
|
.then((text: any) => {
|
||||||
|
const json = '[' + text.trim().split('\n').join(',') + ']';
|
||||||
|
const data = JSON.parse(json);
|
||||||
|
for (let index = 0; index < data.length; index++) {
|
||||||
|
const element = data[index];
|
||||||
|
debug.push(`${server}: image ${element.Name} is in use.`);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((e: any) => console.error(e));
|
||||||
|
|
||||||
|
await fetch(`https://html.${server}.duckdns.org/volumes-dangling-false.jsonl`)
|
||||||
|
.then((res: any) => res.text())
|
||||||
|
.then((text: any) => {
|
||||||
|
const json = '[' + text.trim().split('\n').join(',') + ']';
|
||||||
|
const data = JSON.parse(json);
|
||||||
|
for (let index = 0; index < data.length; index++) {
|
||||||
|
const element = data[index];
|
||||||
|
volumes.push(element.Name);
|
||||||
|
debug.push(`${server}: volume [${element.Name}] is in use.`);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((e: any) => console.error(e));
|
||||||
|
|
||||||
|
await fetch(`https://html.${server}.duckdns.org/containers.jsonl`)
|
||||||
|
.then((res: any) => res.text())
|
||||||
|
.then((text: any) => {
|
||||||
|
const json = '[' + text.trim().split('\n').join(',') + ']';
|
||||||
|
const data = JSON.parse(json);
|
||||||
|
for (let index = 0; index < data.length; index++) {
|
||||||
|
const element = data[index];
|
||||||
|
debug.push(`${server}: container [${element.Name}] is in use.`);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((e: any) => console.error(e));
|
||||||
|
|
||||||
|
for (let index = 0; index < volumes.length; index++) {
|
||||||
|
let check: boolean = false;
|
||||||
|
const volumeExportLine: string | any = volumes[index];
|
||||||
|
volumeExportLines.forEach(element => {
|
||||||
|
if (element.includes(volumeExportLine)) {
|
||||||
|
check = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (check) {
|
||||||
|
debug.push(`${server}: volume [${volumes[index]}] is being exported.`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
warning.push(`${server}: ## 11 * * * podman volume export ${volumes[index]} --output /home/podman/cron-backup/${server}-${volumes[index]}-$(date +"\%Y-\%m-\%d--\%H-\%M-\%S").tar`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await fetch(`https://html.${server}.duckdns.org/volumes-dangling-true.jsonl`)
|
||||||
|
.then((res: any) => res.text())
|
||||||
|
.then((text: any) => {
|
||||||
|
const json = '[' + text.trim().split('\n').join(',') + ']';
|
||||||
|
const data = JSON.parse(json);
|
||||||
|
for (let index = 0; index < data.length; index++) {
|
||||||
|
const element = data[index];
|
||||||
|
debug.push(`${server}: podman volume rm ${element.Name}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((e: any) => console.error(e));
|
||||||
|
|
||||||
|
await fetch(`https://html.${server}.duckdns.org/images-dangling-true.jsonl`)
|
||||||
|
.then((res: any) => res.text())
|
||||||
|
.then((text: any) => {
|
||||||
|
const json = '[' + text.trim().split('\n').join(',') + ']';
|
||||||
|
const data = JSON.parse(json);
|
||||||
|
for (let index = 0; index < data.length; index++) {
|
||||||
|
const element = data[index];
|
||||||
|
debug.push(`${server}: podman image rm ${element.ID}`);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((e: any) => console.error(e));
|
||||||
|
|
||||||
|
await Bun.write(pathA, `${debug.join('\n')}\n${warning.join('\n')}`);
|
26
package.json
26
package.json
@ -1,15 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "adaptation",
|
"name": "adaptation",
|
||||||
"module": "index.ts",
|
"module": "index.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/bun": "latest"
|
"@types/bun": "latest"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"typescript": "^5"
|
"typescript": "^5"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"garbage-collect": "git gc"
|
"garbage-collect": "git gc"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
// Environment setup & latest features
|
// Environment setup & latest features
|
||||||
"lib": ["ESNext"],
|
"lib": ["dom", "ESNext"],
|
||||||
"target": "ESNext",
|
"target": "ESNext",
|
||||||
"module": "Preserve",
|
"module": "Preserve",
|
||||||
"moduleDetection": "force",
|
"moduleDetection": "force",
|
||||||
|
Reference in New Issue
Block a user