#Consistency Tracker Data Wiped After Crash
100 messages · Page 1 of 1 (latest)
i doubt backups are made for these but @gusty crane could prove me wrong
there are backups IN THEORY and from what i heard from people they usually work. but i know of 1 person who said the backups were unrecoverable
go into Celeste\ConsistencyTracker\stats\ and find the file for the map youre playing
if there is a .bak.1 file with a very similar name, thats the backup
so you delete the original file, then rename remove the .bak.1 extension and the _backup from the name (so that the name matches the original files name), then start the game
(that also means close the game first)
in theory, this backup file should be impossible to get corrupted, but i've been proven wrong more than once on this topic 
it can get corrupted if the game freezes while saving to it
renaming it should be a different story though
no, thats not how it works in cct
theres 2 separate files:
- regular stats file
- temp backup file
when the regular stats file is written, instead the temp backup is written to first, then after that its copied over to the regular stats file. in this process, at least to my knowledge, only 1 of the files can become corrupt due to power outages, PC crash, w/e
then, the next time you load into the map, cct can have 2 things happen:
- temp backup file is corrupt, regular stats file is fine -> just load normally
- regular stats file is corrupt, temp backup file is fine -> move the backup file to
.bak.1, then create a new blank file
so unless my assumption for this process is wrong, there should always be at least 1 copy thats working
ah so write ahead backups
alr ill rename the highlighted file and try that
make sure to also remove the _backup from the name, or else it will just get overwritten immediately again
maybe make a safety copy first
got this lil warning, gonna proceed but just putting that out there
yea thats fine
hmm that didn't work

whats inside the json
there is something in the way c# does file IO that i am not understanding
json file of Normal is 3kb
would this be... normal?
oh what about log.txt
where's that
uhh look at the log history folder in the celeste folder
find the one closest to before the crash
i mean i doubt there will be something but yea
i swear i remember having a file just open also made it prone to get corrupted
which is. yea
that's a couple days ago, i would go in LogHistory?
uhh have you started celeste more than 3-4 times
if so then its gone
loghistory has like 3 entries so i guess it might be gone
unfortunate i guess its confirmed then
question: is the write stream closed/flushed before copying?
it doesnt use a stream writer, i only use that for logging. stats writing uses File.WriteAllText
Events.Events 🔥
or can a move operation make the file corrupt??
i mean writealltext has to use a stream
because there is a point where only 1 file exists, when the backup is moved over
uhhhh if the underlying implementation makes a copy and deletes orig then theoretically
i would doubt that? why would it do that
i have no clue
that seems very inefficient
because it is
just changing the file name in the inode(?????????? i think?) makes more sense
i have no clue how this could corrupt files
but i swear long ago i got a file to corrupt just by reading it
idk
i will say, after i implemented the system in this way, people mentioning data corruption became a lot rarer. from ~2-3 per month to 1 every like 2 months, so it Probably helped
@gusty crane @untold sinew hi from another person whose backups doesn't work out too
it's sad to loose 100h of stat but ofc i don't blame you, sometimes programs doesn't work how we want it
here is some logs idk if it somehow will help but anyways
122332, 131128 are before crash and 133627 after
also is it okay that .bak.1 file contains only null's inside it?
im afraid if the .bak.1 file is corrupted then the stats are gone for good 
yeah, I'm over it already, but is bak should normally contain readable json? or null's are okay due binary writing or smth?
it should be readable json, but its only created when the original file is found to have issues, as a copy of the _backup file. a long time ago when i implemented this i thought it was impossible for both the original and the _backup file to become corrupt at the same time, but apparently i was wrong
Just a heads up please make your own help post for your issues in the future. 
If you want to reference some other help post you can send a link to it.
oh, okay, it was just same thing so i decided write it here
Only just now saw this because the post was necrod; you're using a copy instead of a move, and only the latter is atomic afaik
There's still the issue with OS-wide filesystem buffers / the drive itself being corrupted, but of you're intending to use a classic "write to alt file then atomicallly replace" then you definitely want a move instead of a copy
i also used Move in a previous iteration of this system, it still happened
Then it's probably an OS file buffer thing + an abnormal shutdown
Or like full blown disk corruption
i plan on switching the system entirely, so that cct just keeps 2 files and doesnt move/copy/delete anything, and when loading the stats it looks for the most recently edited file and when saving just saves to each file slot in a 1 2 1 2 pattern
which SHOULD make corruption impossible
^huge asterisk here, because im pretty sure i said the same thing like 6 times already
Also, for your consideration: https://learn.microsoft.com/en-us/dotnet/api/system.io.filestream.flush?view=net-9.0#system-io-filestream-flush(system-boolean)
idk, i no longer trust microsoft documentation on this matter. i'd rather find a solution that logically cannot fail, and i hope i got it with this one
and yea its always abnormal shutdown
I see
always after power outages / pc crashes
You should be able to adress that using that overload though
thats the thing: should
maybe, but will it actually work? idk
impossible to test sadly
If that doesn't work then you're just screwed period
But adding that call in should reduce failure cases down to only drive malfunctions, and may your deity of choice help you in that case
Just wanted to point that out as a low-effort fix for something like this
eh, ill switch to my aforementioned thing, which should also work in any other cases like drive malfunction
but thanks for the advice anyways 
speaking of this tho, how does that logically work btw? how can a copy operation corrupt the file that is being copied?
shouldnt that just read, never write?
or im guessing you mean it crashes here (or during the copy, but before backupPath was properly written to disk)