If you create a new savefile, but leave out the filename, you will get a temporary savefile that gets deleted as soon as the reference is gone. The problem is copying the file. If you try to use fcopy() on the temporary savefile, you will be greeted with an ugly safety check popup, since the file is technically outside of the game's directory, even though the game created it and already has full access to it.
Numbered Steps to Reproduce Problem:
1. Create a new project and run the following code:
Code Snippet (if applicable) to Reproduce Problem:
mob
verb
safety_check()
var/savefile/f = new
f << "thing"
fcopy(f, "newsave.sav")
var/savefile/f2 = new("newsave.sav")
var/val
f2 >> val
src << val
no_safety_check()
var/savefile/f = new
f << "thing"
var/savefile/f2 = new("newsave.sav")
f2.ImportText(null, f.ExportText())
var/val
f2 >> val
src << val
2. Click on the verbs and notice how one results in a safety check, and the other doesn't, even though they are both accomplishing the same thing. Unfortunately, the one without the safety check is likely to be much less efficient.
Expected Results:
Both verbs behave exactly the same.
Actual Results:
One has a safety check and the other doesn't.
Does the problem occur:
Every time? Or how often?
Every time.
In other games?
The presence of an actual hub might change the level of access the game has to files in the cache, but I don't know.
In other user accounts?
Probably.
On other computers?
Probably.
When does the problem NOT occur?
I don't think it will occur in trusted mode. It won't occur if the savefile you are copying is a permanent file rather than a temporary one.
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
I have no idea.
Workarounds:
Use ExportText() and ImportText() like in the example above.
Once you've created that temporary savefile you're pretty much limited to what's being done internally to handle the temporary reference, which is a temporary file, that file isn't meant to be used beyond that purpose and when you go to copy it, as you said, you're trying to copy a file from the cache which is going to result in a safety check outside of trusted mode for anything.
To avoid it, don't use a temporary cached savefile, make a new named one then delete it afterwards with fdel(). Name it something nonsensical that nobody would ever have a conflict with (that's how temporary files work in general except they use an actual naming scheme standard), no reason you can't handle it yourself fairly easily.
I'd honestly prefer this to stay how it is because there's probably a whole can of worms of security nonsense it would open.