@@ -1416,17 +1416,22 @@ public async Task<bool> DeleteFileDescriptor(string fullPath, XivDataFile dataFi
1416
1416
/// <returns></returns>
1417
1417
public async Task < bool > AddFileDescriptor ( string fullPath , long dataOffset , XivDataFile dataFile , bool updateCache = true )
1418
1418
{
1419
- if ( ! fullPath . Contains ( ".flag" ) )
1419
+ bool isFlag = false ;
1420
+ if ( ! fullPath . EndsWith ( ".flag" ) )
1420
1421
{
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
+ }
1423
1427
1424
- if ( dataOffset <= 0 )
1428
+ await AddFileDescriptor ( fullPath + ".flag" , - 1 , dataFile , false ) ;
1429
+ } else
1425
1430
{
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 ;
1428
1432
}
1429
1433
1434
+
1430
1435
uint uOffset = ( uint ) ( dataOffset / 8 ) ;
1431
1436
await _semaphoreSlim . WaitAsync ( ) ;
1432
1437
try
@@ -1512,15 +1517,18 @@ public async Task<bool> AddFileDescriptor(string fullPath, long dataOffset, XivD
1512
1517
1513
1518
if ( iHash == uFileHash )
1514
1519
{
1515
- // File already exists. Just update the data offset.
1516
- _semaphoreSlim . Release ( ) ;
1517
- try
1520
+ if ( ! isFlag )
1518
1521
{
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
+ }
1524
1532
}
1525
1533
return false ;
1526
1534
}
0 commit comments