@@ -43,7 +43,8 @@ public async Task ShadowCopy_FailsWithUsefulExceptionMessage_WhenNoPermissionsTo
43
43
Assert . Contains ( shadowCopyDirectory . DirectoryPath , content , StringComparison . InvariantCultureIgnoreCase ) ;
44
44
45
45
shadowCopyDirectory . RestoreAllPermissions ( ) ;
46
- Assert . True ( IsDirectoryEmpty ( shadowCopyDirectory . DirectoryPath ) , "Expected shadow copy shadowCopyDirectory to be empty" ) ;
46
+ // If failed to copy then the shadowCopyDirectory should be empty
47
+ Assert . True ( IsDirectoryEmpty ( shadowCopyDirectory . DirectoryPath ) , "Expected shadow copy directory to be empty" ) ;
47
48
}
48
49
49
50
[ ConditionalFact ]
@@ -73,7 +74,7 @@ public async Task ShadowCopy_FailsWithUsefulExceptionMessage_WhenNoWritePermissi
73
74
74
75
shadowCopyDirectory . RestoreAllPermissions ( ) ;
75
76
// If failed to copy then the shadowCopyDirectory should be empty
76
- Assert . True ( IsDirectoryEmpty ( shadowCopyDirectory . DirectoryPath ) , "Expected shadow copy shadowCopyDirectory to be empty" ) ;
77
+ Assert . True ( IsDirectoryEmpty ( shadowCopyDirectory . DirectoryPath ) , "Expected shadow copy directory to be empty" ) ;
77
78
}
78
79
79
80
[ ConditionalFact ]
@@ -241,7 +242,7 @@ public async Task ShadowCopyDeleteFolderDuringShutdownWorks()
241
242
// Act
242
243
243
244
// Delete folder + file after app is shut down
244
- // Testing specific path on startup where we compare the app shadowCopyDirectory contents with the shadow copy shadowCopyDirectory
245
+ // Testing specific path on startup where we compare the app directory contents with the shadow copy directory
245
246
Directory . Delete ( deleteDirPath , recursive : true ) ;
246
247
247
248
RemoveAppOffline ( deploymentResult . ContentRoot ) ;
@@ -313,18 +314,18 @@ public async Task ShadowCopyE2EWorksWithOldFoldersPresent()
313
314
314
315
// Act & Assert
315
316
response = await deploymentResult . HttpClient . GetAsync ( "Wow!" ) ;
316
- Assert . False ( Directory . Exists ( Path . Combine ( directory . DirectoryPath , "0" ) ) , "Expected 0 shadow copy shadowCopyDirectory to be skipped" ) ;
317
+ Assert . False ( Directory . Exists ( Path . Combine ( directory . DirectoryPath , "0" ) ) , "Expected 0 shadow copy directory to be skipped" ) ;
317
318
318
319
// Depending on timing, this could result in a shutdown failure, but sometimes it succeeds, handle both situations
319
320
if ( ! response . IsSuccessStatusCode )
320
321
{
321
322
Assert . True ( response . ReasonPhrase == "Application Shutting Down" || response . ReasonPhrase == "Server has been shutdown" ) ;
322
323
}
323
324
324
- // This shutdown should trigger a copy to the next highest shadowCopyDirectory , which will be 2
325
+ // This shutdown should trigger a copy to the next highest directory , which will be 2
325
326
await deploymentResult . AssertRecycledAsync ( ) ;
326
327
327
- Assert . True ( Directory . Exists ( Path . Combine ( directory . DirectoryPath , "2" ) ) , "Expected 2 shadow copy shadowCopyDirectory " ) ;
328
+ Assert . True ( Directory . Exists ( Path . Combine ( directory . DirectoryPath , "2" ) ) , "Expected 2 shadow copy directory to exist " ) ;
328
329
329
330
// Act & Assert
330
331
response = await deploymentResult . HttpClient . GetAsync ( "Wow!" ) ;
@@ -360,26 +361,26 @@ public async Task ShadowCopyCleansUpOlderFolders()
360
361
361
362
// Act & Assert
362
363
response = await deploymentResult . HttpClient . GetAsync ( "Wow!" ) ;
363
- Assert . False ( Directory . Exists ( Path . Combine ( shadowCopyDirectory . DirectoryPath , "0" ) ) , "Expected 0 shadow copy shadowCopyDirectory to be skipped" ) ;
364
+ Assert . False ( Directory . Exists ( Path . Combine ( shadowCopyDirectory . DirectoryPath , "0" ) ) , "Expected 0 shadow copy directory to be skipped" ) ;
364
365
365
366
// Depending on timing, this could result in a shutdown failure, but sometimes it succeeds, handle both situations
366
367
if ( ! response . IsSuccessStatusCode )
367
368
{
368
369
Assert . True ( response . ReasonPhrase == "Application Shutting Down" || response . ReasonPhrase == "Server has been shutdown" ) ;
369
370
}
370
371
371
- // This shutdown should trigger a copy to the next highest shadowCopyDirectory , which will be 11
372
+ // This shutdown should trigger a copy to the next highest directory , which will be 11
372
373
await deploymentResult . AssertRecycledAsync ( ) ;
373
374
374
- Assert . True ( Directory . Exists ( Path . Combine ( shadowCopyDirectory . DirectoryPath , "11" ) ) , "Expected 11 shadow copy shadowCopyDirectory " ) ;
375
+ Assert . True ( Directory . Exists ( Path . Combine ( shadowCopyDirectory . DirectoryPath , "11" ) ) , "Expected 11 shadow copy directory " ) ;
375
376
376
377
// Act & Assert
377
378
response = await deploymentResult . HttpClient . GetAsync ( "Wow!" ) ;
378
379
Assert . True ( response . IsSuccessStatusCode ) ;
379
380
380
381
// Verify old directories were cleaned up
381
- Assert . False ( Directory . Exists ( Path . Combine ( shadowCopyDirectory . DirectoryPath , "1" ) ) , "Expected 1 shadow copy shadowCopyDirectory to be deleted" ) ;
382
- Assert . False ( Directory . Exists ( Path . Combine ( shadowCopyDirectory . DirectoryPath , "3" ) ) , "Expected 3 shadow copy shadowCopyDirectory to be deleted" ) ;
382
+ Assert . False ( Directory . Exists ( Path . Combine ( shadowCopyDirectory . DirectoryPath , "1" ) ) , "Expected 1 shadow copy directory to be deleted" ) ;
383
+ Assert . False ( Directory . Exists ( Path . Combine ( shadowCopyDirectory . DirectoryPath , "3" ) ) , "Expected 3 shadow copy directory to be deleted" ) ;
383
384
}
384
385
385
386
[ ConditionalFact ]
@@ -469,7 +470,7 @@ public static int RunCommand(string command, string arguments, ILogger logger, s
469
470
return process . ExitCode ;
470
471
}
471
472
472
- public static void RemoveAllPermissions ( DirectoryInfo directoryInfo )
473
+ internal static void RemoveAllPermissions ( DirectoryInfo directoryInfo )
473
474
{
474
475
var directorySecurity = directoryInfo . GetAccessControl ( ) ;
475
476
@@ -485,7 +486,7 @@ public static void RemoveAllPermissions(DirectoryInfo directoryInfo)
485
486
directoryInfo . SetAccessControl ( emptyPermissions ) ;
486
487
}
487
488
488
- public static void RemoveWritePermissions ( DirectoryInfo directoryInfo )
489
+ internal static void RemoveWritePermissions ( DirectoryInfo directoryInfo )
489
490
{
490
491
var directorySecurity = directoryInfo . GetAccessControl ( ) ;
491
492
// Deny Write access for Everyone
@@ -523,7 +524,10 @@ public TempDirectoryRestrictedPermissions(DirectoryInfo directoryInfo, ILogger l
523
524
524
525
public void RestoreAllPermissions ( )
525
526
{
526
- if ( _hasPermissions ) return ;
527
+ if ( _hasPermissions )
528
+ {
529
+ return ;
530
+ }
527
531
528
532
RestoreAllPermissionsInner ( ) ;
529
533
@@ -539,7 +543,7 @@ private void RestoreAllPermissionsInner()
539
543
540
544
if ( res != 0 )
541
545
{
542
- Logger . LogError ( "Failed to restore permissions for shadowCopyDirectory {DirectoryPath}. Takeown result: {TakeownResult}" , DirectoryPath , res ) ;
546
+ Logger . LogError ( "Failed to restore permissions for directory {DirectoryPath}. Takeown result: {TakeownResult}" , DirectoryPath , res ) ;
543
547
}
544
548
}
545
549
@@ -608,30 +612,30 @@ private static void DeleteDirectory(string directoryPath)
608
612
}
609
613
catch ( Exception e )
610
614
{
611
- Console . WriteLine ( $@ "Failed to delete shadowCopyDirectory { directoryPath } : { e . Message } ") ;
615
+ Console . WriteLine ( $@ "Failed to delete directory { directoryPath } : { e . Message } ") ;
612
616
}
613
617
}
614
618
}
615
619
616
620
// copied from https://learn.microsoft.com/dotnet/standard/io/how-to-copy-directories
617
621
private static void DirectoryCopy ( string sourceDirName , string destDirName , bool copySubDirs , string ignoreDirectory = "" )
618
622
{
619
- // Get the subdirectories for the specified shadowCopyDirectory .
623
+ // Get the subdirectories for the specified directory .
620
624
DirectoryInfo dir = new DirectoryInfo ( sourceDirName ) ;
621
625
622
626
if ( ! dir . Exists )
623
627
{
624
628
throw new DirectoryNotFoundException (
625
- "Source shadowCopyDirectory does not exist or could not be found: "
629
+ "Source directory does not exist or could not be found: "
626
630
+ sourceDirName ) ;
627
631
}
628
632
629
633
DirectoryInfo [ ] dirs = dir . GetDirectories ( ) ;
630
634
631
- // If the destination shadowCopyDirectory doesn't exist, create it.
635
+ // If the destination directory doesn't exist, create it.
632
636
Directory . CreateDirectory ( destDirName ) ;
633
637
634
- // Get the files in the shadowCopyDirectory and copy them to the new location.
638
+ // Get the files in the directory and copy them to the new location.
635
639
FileInfo [ ] files = dir . GetFiles ( ) ;
636
640
foreach ( FileInfo file in files )
637
641
{
0 commit comments