Skip to content

FileInfo(s) APIs refactoring #336

@Utumno

Description

@Utumno

It is not a terrible API per se but:

  • IniInfo have no backups, headers and masters (81746fb, b0e4c7f#diff-9cce2419e77947d069ca14ed8543066bR2096)
  • those two should subclass their files directly (b0e4c7f, b199a7b#diff-9cce2419e77947d069ca14ed8543066bR2936)
  • sameAs is not a bad idea but needs_update may be better (ad79e70)
  • refresh ! needs rewrite to be more granular and the different kinds of infos complicate this a lot (ghosts, default tweaks...) -> Refresh Optimizations II #353 (for this issue specific see for instance ad79e70, 25a2055)
  • bosh.ModInfos#refreshFile <--- revisit
  • needs_update refreshFile rename (_cache_updated, add_info)
  • CorruptedFile(AFile) class to further optimize refresh (now it always recheck corrupted, plus we do not have an easy way to mark BSAs as corrupted when their cache is read) See: _reset_cache rewrite to unify refresh -> actually no - just add a corrupted attribute -> a1c5a36
    • Corrupt files don't get refreshed properly when deleted: create empty TXT file, change extension to ESP, refresh WB, delete it, refresh WB -> traceback
  • cachedCrc/setmtime - crc is not correctly updated in some cases - see Reworking AFile API - keeping ctime - WIP commit
  • self.abs_path -> use sparingly, don't want a new getPath (moving logic into ListInfos helps)
  • incorporate Installers and screens to this AFile API - see e007a53 / beef63c
  • remove table - use it only to load/save the 'persistent' (see Installer) attributes - then get/set attributes to the infos accordingly -> ca48e96 and in particular fe29d71 (also 82aa8d7 for time travelers) - now cause table was there a lot of operations that create a new info needed to now manually copy the "persistent" attributes - so this will take some fixing (see for instance 641a079) - explicit is better than implicit though and the complexity went over a cliff (as now we don't need to update the table but on loading/saving)
    • BSAInfo no masters - but table first this is nit -> 7f73b7e
  • use the persistent/volatile ListInfo attributes to properly implement rename! (again see Installer copy_to)
  • use Afile for load_order files -> e0171ff and rest of that merge

File operations - we need to mark_unchanged if using the python methods but SHFileOperation will preserve c/mtime - all this part of the API needs rewrite, it's system's programming after all, generally a hard subject. See Slight optimizations in rename:


Rename/Hide/Backup and co fall into two categories: copying and moving files. We should rethink our internal APIs for copying/moving and then rewrite those operations as thin wrappers (passing the right paths in) around a copy/move API. Those operations should be as atomic as the filesystem permits. Moreover, when renaming/hiding/backing up/moving in save profiles etc multiple files we should construct all the source/paths at once and issue one system call - see for instance _try_rename that does this per file...


I created an AFile class to represent a file with a cache check for mod times and size but it's difficult to plug it in. Opening this to document/coordinate the refactoring.

Metadata

Metadata

Assignees

Labels

A-filesystemArea: File operations, filenames handling, OSs support (everywhere)C-goalCategory: Long term goal. May be code-related or a meta goal.C-internalCategory: Keep track of internal refactoring. Implies the C-todo label except if it is a full C-goal

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions