fix: clean up stale raw mounts before scanning in attach wizard
After an interrupted attach wizard, the raw mount stays behind, causing the device to appear as "mounted" in scan results. Now the scan button calls cancel first, which unmounts any stale raw mounts that have no bind mount in fstab. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1071,22 +1071,23 @@ func (s *Server) storageAttachStatusAPIHandler(w http.ResponseWriter, r *http.Re
|
||||
|
||||
// storageAttachCancelHandler handles POST /api/storage/attach/cancel.
|
||||
// Cleans up the temporary raw mount when the user cancels the wizard.
|
||||
// Also cleans up any stale raw mounts from interrupted previous sessions.
|
||||
func (s *Server) storageAttachCancelHandler(w http.ResponseWriter, r *http.Request) {
|
||||
s.diskJobMu.Lock()
|
||||
rawMount := s.activeRawMount
|
||||
s.activeRawMount = ""
|
||||
s.diskJobMu.Unlock()
|
||||
|
||||
if rawMount == "" {
|
||||
jsonResponse(w, map[string]interface{}{"ok": true, "msg": "Nincs aktív raw mount"})
|
||||
return
|
||||
if rawMount != "" {
|
||||
if err := storage.CleanupRawMount(rawMount); err != nil {
|
||||
s.logger.Printf("[WARN] Failed to cleanup raw mount %s: %v", rawMount, err)
|
||||
} else {
|
||||
s.logger.Printf("[INFO] Cleaned up raw mount: %s", rawMount)
|
||||
}
|
||||
}
|
||||
|
||||
if err := storage.CleanupRawMount(rawMount); err != nil {
|
||||
s.logger.Printf("[WARN] Failed to cleanup raw mount %s: %v", rawMount, err)
|
||||
} else {
|
||||
s.logger.Printf("[INFO] Cleaned up raw mount: %s", rawMount)
|
||||
}
|
||||
// Also clean up any stale raw mounts from previous interrupted sessions
|
||||
storage.CleanupStaleRawMounts()
|
||||
|
||||
jsonResponse(w, map[string]interface{}{"ok": true, "msg": "Raw mount eltávolítva"})
|
||||
jsonResponse(w, map[string]interface{}{"ok": true})
|
||||
}
|
||||
|
||||
@@ -167,7 +167,11 @@ function scanDisks() {
|
||||
errEl.style.display = 'none';
|
||||
resultEl.style.display = 'none';
|
||||
|
||||
fetch('/api/storage/scan', {method:'POST'})
|
||||
// Clean up any stale raw mounts from interrupted previous sessions first,
|
||||
// so the device appears as available in the scan results.
|
||||
fetch('/api/storage/attach/cancel', {method:'POST'})
|
||||
.catch(function(){}) // ignore cancel errors
|
||||
.then(function() { return fetch('/api/storage/scan', {method:'POST'}); })
|
||||
.then(function(r){ return r.json(); })
|
||||
.then(function(data) {
|
||||
btn.textContent = '🔍 Meghajtók keresése';
|
||||
|
||||
Reference in New Issue
Block a user