Mass delete player ...
 
Notifications
Clear all

Mass delete player files

2 Posts
2 Users
0 Reactions
748 Views
(@gecko64)
Posts: 82
Estimable Member
Topic starter
 

We use the Player Files for saved-game files, and generally it works great. However, one player has got....maybe 100 or more of these files, and it's causing problems with our sync function in the game. (Or maybe one of those files is corrupted, not sure.) Anyways, I need to delete all those files. I can do that one by one, but because there are so many of them, it takes Combu a full minute or two to load the player page each and every time. Is there an easy and safe way to mass-delete the files? I know I can do it easily in the PlayerFiles table in phpMyAdmin, but would that cause any data-consistency problems?

 
Posted : 20/12/2017 4:45 pm
(@skaredcreations)
Posts: 805
Prominent Member Admin
 

If you delete the records in phpMyAdmin you will still have the physical files on the server hard disk (that will not be accessed from clients any more because not associated to a record), besides that garbage there's no data-consistency issues.

Else you'll need to create a coroutine to delete all files of your localUser (or if meet some conditions), like (not tested):

IEnumerator DeleteUserFiles()
{
	bool wait = false, quit = false;
	const int countPerPage = 5;
	int pageNumber = 1;
	while (!quit)
	{
		wait = true;
		UserFile.Load (CombuManager.localUser.id, false, pageNumber, countPerPage, (UserFile[] files, int recordsCount, int pagesCount, string error) => 
		{
			if (recordsCount > 0) {
				foreach (UserFile file in files) {
					file.Delete (null);
				}
				// Move to next page
				pageNumber++;
				if (pageNumber >= pagesCount)
				{
					quit = true;
				}
				wait = false;
			} else {
				// No more files
				quit = true;
				wait = false;
			}
		});
		while (wait)
		{
			yield return null;
		}
	}
}

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 21/12/2017 9:20 pm
Share: