Temporary FolderItems - Recovered Items in Trash

One of my macOS clients is reporting that if they run my app then reboot, upon rebooting they are left with files in the Recovered Items in the Trash folder. This is under 10.11 and 10.12.

I believe what’s happening is related to this: https://forum.xojo.com/conversation/post/130210

Although it may be normal behavior I’m wondering what best practices are now, especially given that Sierra now has the Optimize Storage feature (About this Mac / Storage / Manage…)

I’d like to make sure my temporary folder items never end up in Recovered Items. But I’d also like the OS to be able to clean them up automatically if necessary.

Is there a location that meets both needs?

You could try items in /tmp or in special folders.temporary.parent

Looking into it further, I think it may be the files that Xojo uses for Mutex objects? That wouldn’t be something I can control necessarily.

This seems to be a widespread problem. Can anyone else confirm?

Please test this:

Upon restart, look in your Trash folder. You will see a Recovered Files folder and inside it will be zero-byte files which are named the same as the Mutex objects.

This behavior is being seen with a variety of Xojo versions (from 2014R2.1 thru 2017.x).

I have a customer complaining about this and wanting a refund, so (for me) it’s a serious issue and I’d like to understand the problem and fix it if possible.

You could move to use temporary folder’s parent folder for this instead.
Or your own folder in ~/Library/Cache folder.

[quote=340812:@Christian Schmitz]You could move to use temporary folder’s parent folder for this instead.
Or your own folder in ~/Library/Cache folder.[/quote]

Setting the path isn’t possible with http://documentation.xojo.com/index.php/Mutex Mutex objects, is it?

and ist it really a good idea to fight against the OS?
At least the temp-folder is cleaned up by the OS so that there are no left over files. Using another folder would fill up the disk…

Were you able to solve this issue? Got a user complaining about this, too.

Thats the second best excuse I have heard .

The first being

‘even though I went to your website, tried the demo, bought the software with my Paypal account, downloaded it, installed it 2 months ago and registered it from my own IP address with my own email address -
this was a fraudulent sale’.

Im curious: in what way did this inconvenience the customer?

And could you look in the trash folder for files that match your naming pattern, and delete them on startup?

Warning: Tomorrow customers will ask a module to build a story after giving the software a bunch of words (less than 10) and selecting a “domain” (say Police Story, Romance, Science Fiction and so on…) ?

When will customers start to ask for an ESP module ?

Sometimes I am at short (the reading let me with no idea, nothing to say, that is why I do not chime in on Jul 6.)

Let’s not discuss about customers. They concentrate on simple things. Some are more detail orientated than others. If there is a simple way to fix this issue I’d like to do it.

There is. Instead of just creating, using temporary folderitems and letting them go out of scope, create a new class which contains a temporary folderitem which will automatically delete the file(s) for you when the class’ destructor fires.

I’ll try that. Hmm… that must be the file for the Valentina diagnosis I do after adding data.

Greg, the problem seems to come from Mutex objects, which do not provide any options for where the temp file is located.

Recovered Items ?
I have data there each time I fire Xojo and watch the Language Reference.

Howecer, isn’t SpecialFolder.Temporary holds these files i a folder (called Recovered Items) ?

If so, I would add code in Cancel Quit (or Quit) Event that scan that folder and if it find a folder called Recovered Items, open it, clears it and delete it (at last).

Isn’t it possible to do that ?

[quote=341912:@Emile Schwarz]Recovered Items ?
If so, I would add code in Cancel Quit (or Quit) Event that scan that folder and if it find a folder called Recovered Items, open it, clears it and delete it (at last).

Isn’t it possible to do that ?[/quote]

I believe that leftover items in the Temp folder are moved to the Trash/Recovered Items folder upon reboot, so that your Xojo app would never have a chance to do that, unless your Xojo app runs automatically upon login (which mine does not).


The folder may be stored elsewhere in the hidden OS files.

I’ve made a search including System Files + visibles but I do not found one, before reboot.

Time to sleep now.

Edit: finish a sentence and add the last one.

I’m curious why the mutex file isn’t being destroyed when you call Mutex.Leave as your app quits. We use a mutex for Feedback and it doesn’t suffer from this problem.

I don’t know if it’s a mutex causing this, but Feedback is leaving a temporary file behind. I just opened Feedback 2017r1.2, then closed it and logged out. Upon logging back in my .Trash directory contained a 0 byte file named “Xojo Feedback” in a dir named “Recovered files”.

Here’s info on that file:

$ ls -l@ -rw-r--r--@ 1 user staff 0 Jul 25 06:55 Xojo Feedback com.apple.FinderInfo 32

This is on OSX 10.11.6.

I just did a quick test. Entering a Mutex does indeed create a file in Temporary, and Leaving it deletes it. Quitting without explicitly calling Leave deletes it too, but perhaps if it’s located somewhere where its Destructor doesn’t necessarily fire, it won’t.

If it’s the Mutex at all, perhaps explicitly call Leave in the App Destructor? Or do what I do, create a wrapper class that holds the Mutex (or a Semaphore or CriticalSection) that calls Leave in it’s Destructor. I use it like this:

dim m as new Mutex( "MyApp" )
dim holder as CSHolder = CSHolder.TryEnter( m )
if holder is nil then
  // Couldn't get it
  // Some code
  holder.Leave // Not strictly necessary as its Destructor will Leave it
end if

If your code exits early from, say, an exception or early return, the Mutex should still be unset.