jcs
/amend
/amendments
/117
repo: Stop storing TMPLs, we're not using resource files anymore
jcs made amendment 117 about 1 year ago
--- repo.c Tue Mar 28 15:20:43 2023
+++ repo.c Tue Apr 18 15:42:15 2023
@@ -1119,13 +1119,7 @@ repo_marshall_amendment(struct repo_amendment *amendme
short
repo_migrate(struct repo *repo, bool is_new)
{
- struct bile_object *bob;
- Str255 tname;
- Handle h;
- size_t size;
unsigned long id;
- OSType type, tmpltype;
- short i, ntmpls;
char ver;
if (is_new)
@@ -1148,52 +1142,25 @@ repo_migrate(struct repo *repo, bool is_new)
}
/* per-version migrations */
-
/* 1 had no version number :( */
- /* 1->2 added a version */
- /* 2->3 was switching from resource forks to bile */
-
+ while (ver < REPO_CUR_VERS) {
+ switch (ver) {
+ case 1:
+ /* 1->2 added a version */
+ break;
+ case 2:
+ /* 2->3 was switching from resource forks to bile */
+ break;
+ }
+
+ ver++;
+ }
+
/* store new version */
ver = REPO_CUR_VERS;
if (bile_write(repo->bile, REPO_VERS_RTYPE, 1, &ver, 1) != 1)
panic("Failed writing new version: %d", bile_error(repo->bile));
- bile_verify(repo->bile);
-
- progress("Copying templates...");
-
- /* copy templates from our resource file to bile file */
- while ((bob = bile_get_nth_of_type(repo->bile, 0, 'TMPL')) != NULL) {
- bile_delete(repo->bile, 'TMPL', bob->id);
- xfree(&bob);
- }
-
- ntmpls = Count1Resources('TMPL');
- for (i = 0; i < ntmpls; i++) {
- h = GetIndResource('TMPL', i + 1);
- if (h == NULL)
- panic("Failed fetching TMPL %d", i + 1);
- GetResInfo(h, &id, &type, &tname);
-
- /*
- * The template name should be an OSType as a string, use it as
- * the id
- */
- if (tname[0] != 4)
- panic("TMPL %ld has bogus name \"%s\"", id, PtoCstr(tname));
- tmpltype = ((unsigned long)tname[1] << 24) |
- ((unsigned long)tname[2] << 16) |
- ((unsigned long)tname[3] << 8) |
- ((unsigned long)tname[4]);
- size = bile_write(repo->bile, 'TMPL', tmpltype, *h,
- GetHandleSize(h));
- if (size != GetHandleSize(h))
- panic("short write saving TMPL %ld: %d", id,
- bile_error(repo->bile));
-
- DetachResource(h);
- }
-
progress("Doing a full check of the new repo...");
bile_verify(repo->bile);