Gumpf

Post

Posted
Rating:
#1 (In Topic #1367)
Guru
BruceSteers is in the usergroup ‘Guru’
I have added an option in the IDE to remove all the gambas dead folders when gambas starts.

i have now also added ~/.cache to the list as i found over 800 org.gambas.* dead folders in there.

But i made a quick gbs script for everyone.. (attached)
Attachment

it checks for residual gambas folders matching…

/tmp/gambas.1000/****
/run/user/1000/gambas/****
$HOME/.local.share/org.gambas.****
$HOME/.cache/org.gambas.****

It checks if the number (ID) of the folder number matches a running process ID in /proc/

Lists all orphaned folders that no longer match a live process ID and offers to clean up if you want..

PS. i think if your programs use Quit to exit you have more chance of getting these dead folders as when a program is Quit it does not clean up after itself like in a normal clean exit.

Like i said i found over 800 folders in ~/.cache the other day  :o
All it takes is logging out/shutting down while a program is running.

I'd be curious to know if anyone else finds a shockingly large amount of dead folders, just run the attached gb_gumph script in a terminal.

PPS. the temporary folders in /tmp/gambas.1000/ (File.Dir(File.Dir(Temp()))) and /run/user/1000/gambas (Env["XDG_RUNTIME_DIR"] &/ "gambas")  don't mean very much as they get destroyed on each reboot. If you do find a lot of stuff in them it's probably due to program using Quit.  Thee files in $HOME are there for good unless we remove the unused ones.

This is my output (after about only 2 hours from my last clean) 41 orphans already.

Code

bonus:~$ gb_gumph
Items with a matching process...
/tmp/gambas.1000/4131  ok
/tmp/gambas.1000/2665  ok
/tmp/gambas.1000/7247  ok
/tmp/gambas.1000/2664  ok
/tmp/gambas.1000/7245  ok
/tmp/gambas.1000/2823  ok
/run/user/1000/gambas/4131  ok
/run/user/1000/gambas/2664  ok

Orphaned items...
~/.cache/org.gambas.102814
~/.cache/org.gambas.100140
~/.cache/org.gambas.95099
~/.cache/org.gambas.5046
~/.cache/org.gambas.90194
~/.cache/org.gambas.102376
~/.cache/org.gambas.6278
~/.cache/org.gambas.91214
~/.cache/org.gambas.88770
~/.cache/org.gambas.93793
~/.cache/org.gambas.93158
~/.cache/org.gambas.94453
~/.cache/org.gambas.91859
~/.cache/org.gambas.92498
~/.local/share/org.gambas.17016
~/.local/share/org.gambas.102814
~/.local/share/org.gambas.100140
~/.local/share/org.gambas.22804
~/.local/share/org.gambas.6476
~/.local/share/org.gambas.16855
~/.local/share/org.gambas.7157
~/.local/share/org.gambas.13833
~/.local/share/org.gambas.5046
~/.local/share/org.gambas.17305
~/.local/share/org.gambas.102376
~/.local/share/org.gambas.7521
~/.local/share/org.gambas.7868
~/.local/share/org.gambas.6278
~/.local/share/org.gambas.8156
~/.local/share/org.gambas.11823
~/.local/share/org.gambas.17084
~/.local/share/org.gambas.6875
~/.local/share/org.gambas.6596
~/.local/share/org.gambas.31694
~/.local/share/org.gambas.6248
/tmp/gambas.1000/6961
/tmp/gambas.1000/6571
/tmp/gambas.1000/6966
/tmp/gambas.1000/6566
/run/user/1000/gambas/5046
/run/user/1000/gambas/6278

Found 14 orphaned items in ~/.cache
Found 21 orphaned items in ~/.local/share
Found 4 orphaned items in /tmp/gambas.1000
Found 2 orphaned items in /run/user/1000/gambas

Found a total of 41 orphaned items...
Type y to delete them or return to quit.

The script…

Code (gambas)

  1. #!/usr/bin/env gbs3
  2. Public Sub Main()
  3.  
  4.   Dim aPaths As String[] = ["~/.cache", "~/.local/share", File.Dir(File.Dir(Temp())), Env["XDG_RUNTIME_DIR"] &/ "gambas"]
  5.   Dim aList As String[]
  6.   Dim aFound As New String[]
  7.   Dim aMsg As New String[]
  8.   Dim sProc As String
  9.  
  10.   Print "Items with a matching process..."
  11.   For Each sDir As String In aPaths
  12.  
  13.     If InStr(sDir, "1000") Then
  14.       aList = Dir(sDir, "[0-9]*", gb.Directory)
  15.     Else
  16.       aList = Dir(sDir, "org.gambas.*", gb.Directory)
  17.     Endif
  18.     For c As Integer = aList.Max DownTo 0
  19.  
  20.       sProc = file.Name(aList[c])
  21.       If sProc Begins "org.gambas" Then sProc = Mid(aList[c], 12)
  22.  
  23.       If Exist("/proc/" & sProc) Then
  24.         Print sDir &/ aList[c];; " \e[92mok\e[0m"
  25.         aList.Remove(c)
  26.       Else
  27.         aList[c] = sDir &/ aList[c]
  28.       Endif
  29.     Next
  30.     aFound.insert(aList)
  31.     aMsg.Add("\e[" & If(aList.Count, "91", "92") & ";3mFound " & aList.Count & " orphaned items\e[0m in " & sDir)
  32.   Next
  33.  
  34. If aFound.Count = 0 Then
  35. Print "\n\e[92;3mNo obsolete folders found :)\e[0m"
  36.  
  37.   Print "\nOrphaned items..."
  38.   Print "\e[0m"; aMsg.Join("\n")
  39.   Print "\n\e[91;3mFound a total of " & aFound.Count & " orphaned items\e[0m..."
  40.  
  41.   Print "Type y to delete them or return to quit."
  42.   sDir = File.In.readline()
  43.   If LCase(sDir) = "y" Then
  44.     For Each sDir In aFound
  45.     If Left(sDir) = "~" Then sDir = user.Home &/ Right(sDir, -1)
  46.       Shell "rm -vrf " & sDir Wait
  47.     Next
  48.  
  49.  
  50.  
Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
It seems these folders ARE a result of using Quit   :roll:

It warns on the wiki that you should not use Quit in a GUI application.
I guess it's right.

I am guilty of this an a couple of my programs , I am removing Quit as the easy exit on them and fixing why i needed to use it in the first place.
Online now: No Back to the top

Post

Posted
Rating:
#3
Guru
BruceSteers is in the usergroup ‘Guru’
Benoit has kindly added some things to help reduce these temporary folders getting left behind.
It is much better now :)

you may still find gumph when developing a program as the program might crash while testing then it does not go through it exit routine and clean up.

I'm currently writing a program to monitor/manage/auto-remove any gambas gumph
Online now: No Back to the top

Post

Posted
Rating:
#4
Guru
BruceSteers is in the usergroup ‘Guru’
I've started a tool for managing/detecting source of obsolete folders

Gambas One - Gambas ONE
Online now: No Back to the top
1 guest and 0 members have just viewed this.