Skip to content

Commit

Permalink
Flush the cache after operations
Browse files Browse the repository at this point in the history
  • Loading branch information
Xpl0itU committed Oct 31, 2022
1 parent 9f4cf6e commit 32012d7
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/savemng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,16 @@ void copySavedata(Title *title, Title *titleb, int8_t allusers, int8_t allusers_
if (copyDir(srcPath + stringFormat("/%s", wiiuacc[allusers].persistentID),
dstPath + stringFormat("/%s", wiiuacc[allusers_d].persistentID)) != 0)
promptError(gettext("Copy failed."));

if (dstPath.rfind("storage_slccmpt01:", 0) == 0) {
FSAFlushVolume(handle, "/vol/storage_slccmpt01");
} else if(dstPath.rfind("storage_mlc01:", 0) == 0) {
FSAFlushVolume(handle, "/vol/storage_mlc01");
} else if(dstPath.rfind("storage_usb01:", 0) == 0) {
FSAFlushVolume(handle, "/vol/storage_usb01");
} else if(dstPath.rfind("storage_usb02:", 0) == 0) {
FSAFlushVolume(handle, "/vol/storage_usb02");
}
}

void backupAllSave(Title *titles, int count, OSCalendarTime *date) {
Expand Down Expand Up @@ -877,6 +887,15 @@ void backupSavedata(Title *title, uint8_t slot, int8_t allusers, bool common) {
Date *dateObj = new Date(title->highID, title->lowID, slot);
dateObj->set(date);
delete dateObj;
if (dstPath.rfind("storage_slccmpt01:", 0) == 0) {
FSAFlushVolume(handle, "/vol/storage_slccmpt01");
} else if(dstPath.rfind("storage_mlc01:", 0) == 0) {
FSAFlushVolume(handle, "/vol/storage_mlc01");
} else if(dstPath.rfind("storage_usb01:", 0) == 0) {
FSAFlushVolume(handle, "/vol/storage_usb01");
} else if(dstPath.rfind("storage_usb02:", 0) == 0) {
FSAFlushVolume(handle, "/vol/storage_usb02");
}
}

void restoreSavedata(Title *title, uint8_t slot, int8_t sdusers, int8_t allusers, bool common) {
Expand Down Expand Up @@ -915,6 +934,16 @@ void restoreSavedata(Title *title, uint8_t slot, int8_t sdusers, int8_t allusers

if (copyDir(srcPath, dstPath) != 0)
promptError(gettext("Restore failed."));

if (dstPath.rfind("storage_slccmpt01:", 0) == 0) {
FSAFlushVolume(handle, "/vol/storage_slccmpt01");
} else if(dstPath.rfind("storage_mlc01:", 0) == 0) {
FSAFlushVolume(handle, "/vol/storage_mlc01");
} else if(dstPath.rfind("storage_usb01:", 0) == 0) {
FSAFlushVolume(handle, "/vol/storage_usb01");
} else if(dstPath.rfind("storage_usb02:", 0) == 0) {
FSAFlushVolume(handle, "/vol/storage_usb02");
}
}

void wipeSavedata(Title *title, int8_t allusers, bool common) {
Expand Down Expand Up @@ -952,6 +981,15 @@ void wipeSavedata(Title *title, int8_t allusers, bool common) {
if (unlink(origPath) == -1)
promptError(gettext("Failed to delete user folder.\n%s"), strerror(errno));
}
if (strncmp(strchr(srcPath, '_'), "_usb01", 6) == 0) {
FSAFlushVolume(handle, "/vol/storage_usb01");
} else if (strncmp(strchr(srcPath, '_'), "_usb02", 6) == 0) {
FSAFlushVolume(handle, "/vol/storage_usb02");
} else if (strncmp(strchr(srcPath, '_'), "_mlc", 4) == 0) {
FSAFlushVolume(handle, "/vol/storage_mlc01");
} else if (strncmp(strchr(srcPath, '_'), "_slccmpt", 8) == 0) {
FSAFlushVolume(handle, "/vol/storage_slccmpt01");
}
}

void importFromLoadiine(Title *title, bool common, int version) {
Expand Down

0 comments on commit 32012d7

Please sign in to comment.