2 Commits

Author SHA1 Message Date
87c404828c add powershell run scripts 2025-05-04 17:44:57 +02:00
b074e8eb44 Dhfs-fs: proper not found unlink exception 2025-05-04 17:13:43 +02:00
4 changed files with 124 additions and 0 deletions

View File

@@ -218,6 +218,8 @@ public class DhfsFileServiceImpl implements DhfsFileService {
public void unlink(String name) {
jObjectTxManager.executeTx(() -> {
var node = getDirEntryOpt(name).orElse(null);
if (node == null)
throw new StatusRuntimeException(Status.NOT_FOUND.withDescription("File not found when trying to unlink: " + name));
if (node.meta() instanceof JKleppmannTreeNodeMetaDirectory f) {
if (!allowRecursiveDelete && !node.children().isEmpty())
throw new DirectoryNotEmptyException();

48
run-wrapper/run.ps1 Normal file
View File

@@ -0,0 +1,48 @@
$ErrorActionPreference = 'Stop'
$PIDFILE = Join-Path $PSScriptRoot ".pid"
$EXTRAOPTS = Join-Path $PSScriptRoot "extra-opts"
if (-Not (Test-Path $EXTRAOPTS)) {
New-Item -ItemType File -Path $EXTRAOPTS | Out-Null
}
if (Test-Path $PIDFILE) {
$ReadPID = Get-Content $PIDFILE
if (Get-Process -Id $ReadPID -ErrorAction SilentlyContinue) {
Write-Host "Already running: $ReadPID"
exit 2
}
}
$ExtraOptsParsed = Get-Content $EXTRAOPTS | Where-Object {$_}
Write-Host "Extra options: $($ExtraOptsParsed -join ' ')"
$JAVA_OPTS = @(
"-Xmx512M"
"--enable-preview"
"-Ddhfs.objects.writeback.limit=134217728"
"-Ddhfs.objects.lru.limit=134217728"
"--add-exports", "java.base/sun.nio.ch=ALL-UNNAMED"
"--add-exports", "java.base/jdk.internal.access=ALL-UNNAMED"
"--add-opens=java.base/java.nio=ALL-UNNAMED"
"-Ddhfs.objects.persistence.files.root=$($PSScriptRoot)\..\data\objects"
"-Ddhfs.objects.persistence.stuff.root=$($PSScriptRoot)\..\data\stuff"
"-Ddhfs.objects.persistence.lmdb.size=1000000000"
"-Ddhfs.fuse.root=Z:\"
"-Dquarkus.http.host=0.0.0.0"
'-Dquarkus.log.category.\"com.usatiuk\".level=INFO'
'-Dquarkus.log.category.\"com.usatiuk.dhfs\".level=INFO'
"-Ddhfs.webui.root=$($PSScriptRoot)\Webui"
) + $ExtraOptsParsed + @(
"-jar", "`"$PSScriptRoot\Server\quarkus-run.jar`""
)
$Process = Start-Process -FilePath "java" -ArgumentList $JAVA_OPTS `
-RedirectStandardOutput "$PSScriptRoot\quarkus.log" `
-RedirectStandardError "$PSScriptRoot\quarkus.log.err" `
-NoNewWindow -PassThru
Write-Host "Started $($Process.Id)"
$Process.Id | Out-File -FilePath $PIDFILE

24
run-wrapper/stop.ps1 Normal file
View File

@@ -0,0 +1,24 @@
$ErrorActionPreference = 'Stop'
$PIDFILE = Join-Path $PSScriptRoot ".pid"
if (-Not (Test-Path $PIDFILE)) {
Write-Host "Not running"
exit 2
}
$ReadPID = Get-Content $PIDFILE
if (-Not (Get-Process -Id $ReadPID -ErrorAction SilentlyContinue)) {
Write-Host "Not running"
Remove-Item $PIDFILE -Force
exit 2
}
Write-Host "Killing $ReadPID"
# TODO: Graceful shutdown
Stop-Process -Id $ReadPID
Remove-Item $PIDFILE -Force

50
run-wrapper/update.ps1 Normal file
View File

@@ -0,0 +1,50 @@
$ErrorActionPreference = 'Stop'
$PIDFILE = Join-Path $PSScriptRoot ".pid"
$VERSION_FILE = Join-Path $PSScriptRoot "version"
if (Test-Path $PIDFILE) {
$ReadPID = Get-Content $PIDFILE
if (Get-Process -Id $ReadPID -ErrorAction SilentlyContinue) {
Write-Host "Already running: $ReadPID"
exit 2
}
}
$response = Invoke-RestMethod -Uri "https://api.github.com/repos/usatiuk/dhfs/actions/runs?branch=main&status=completed&per_page=1"
$LATEST = $response.workflow_runs[0].id
Write-Host "Latest: $LATEST"
$CUR = (Get-Content $VERSION_FILE -Raw).Trim()
Write-Host "Current: $CUR"
if ([long]$CUR -ge [long]$LATEST) {
Write-Host "Already latest!"
exit 1
}
Write-Host "Downloading..."
Set-Location $PSScriptRoot
$zipFile = "Run wrapper.zip"
$tarFile = "run-wrapper.tar.gz"
$dhfsDir = "dhfs"
Remove-Item $zipFile, $tarFile -Force -ErrorAction SilentlyContinue
Remove-Item $dhfsDir -Recurse -Force -ErrorAction SilentlyContinue
Invoke-WebRequest -Uri "https://nightly.link/usatiuk/dhfs/actions/runs/$LATEST/Run%20wrapper.zip" -OutFile $zipFile
Expand-Archive -LiteralPath $zipFile -DestinationPath $PSScriptRoot
Remove-Item $zipFile -Force
tar -xf $tarFile --strip-components=2
Remove-Item $tarFile -Force
Remove-Item "Server", "Webui", "NativeLibs" -Recurse -Force -ErrorAction SilentlyContinue
Move-Item "$dhfsDir\app\*" . -Force
Remove-Item $dhfsDir -Recurse -Force
Write-Host "Update complete!"