Skip to content

Commit 67eb570

Browse files
committed
Adjustments to allow .flag files to still write 0 offsets, but no other file types.
1 parent 0c6151d commit 67eb570

File tree

1 file changed

+22
-14
lines changed
  • xivModdingFramework/SqPack/FileTypes

1 file changed

+22
-14
lines changed

xivModdingFramework/SqPack/FileTypes/Index.cs

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,17 +1416,22 @@ public async Task<bool> DeleteFileDescriptor(string fullPath, XivDataFile dataFi
14161416
/// <returns></returns>
14171417
public async Task<bool> AddFileDescriptor(string fullPath, long dataOffset, XivDataFile dataFile, bool updateCache = true)
14181418
{
1419-
if(!fullPath.Contains(".flag"))
1419+
bool isFlag = false;
1420+
if(!fullPath.EndsWith(".flag"))
14201421
{
1421-
await AddFileDescriptor(fullPath + ".flag", -1, dataFile, false);
1422-
}
1422+
if (dataOffset <= 0)
1423+
{
1424+
// Don't let us write totally invalid offsets to the indexes.
1425+
throw new InvalidDataException("Cannot write invalid data offset to file.");
1426+
}
14231427

1424-
if(dataOffset <= 0)
1428+
await AddFileDescriptor(fullPath + ".flag", -1, dataFile, false);
1429+
} else
14251430
{
1426-
// Don't let us write totally invalid offsets to the indexes.
1427-
throw new InvalidDataException("Cannot write invalid data offset to file.");
1431+
isFlag = true;
14281432
}
14291433

1434+
14301435
uint uOffset = (uint)(dataOffset / 8);
14311436
await _semaphoreSlim.WaitAsync();
14321437
try
@@ -1512,15 +1517,18 @@ public async Task<bool> AddFileDescriptor(string fullPath, long dataOffset, XivD
15121517

15131518
if (iHash == uFileHash)
15141519
{
1515-
// File already exists. Just update the data offset.
1516-
_semaphoreSlim.Release();
1517-
try
1520+
if (!isFlag)
15181521
{
1519-
await UpdateDataOffset(dataOffset, fullPath, updateCache);
1520-
}
1521-
finally
1522-
{
1523-
await _semaphoreSlim.WaitAsync();
1522+
// File already exists. Just update the data offset.
1523+
_semaphoreSlim.Release();
1524+
try
1525+
{
1526+
await UpdateDataOffset(dataOffset, fullPath, updateCache);
1527+
}
1528+
finally
1529+
{
1530+
await _semaphoreSlim.WaitAsync();
1531+
}
15241532
}
15251533
return false;
15261534
}

0 commit comments

Comments
 (0)