Open gurcei opened 3 years ago
Implemented in: 52a70474 c98499b1 9901cc80
is_fragmented can still be optimized a bit (no need to go through the whole file, if it finds the first non-consecutive cluster, it can return fragmentation directly). And it needs to be used, which is not done yet.
So this is no defrag command, but it will not reuse an existing files clusters if it was fragmented, and instead delete it, so that it is recreated in one continues clusterchain.
I think that should solve this issue.
A little Discord discussion on this recently:
My thoughts for it are:
1) For a future defrag MYFILE.D81 command, behind the scenes, I'd just be doing a get, delete and put behind the scenes.
2) For the case of trying to put MYFILE.D81 where it already exists on the sd-card in a fragmented state, I've added a function into mega65_ftp.c called is_fragmented(filename) to check if an existing file is fragmented. So the logic here could be: