Skip to content

Commit 038e0ca

Browse files
Fix PhysicalDirectoryArtifactImportOnStartupProvider example code
1 parent 3237235 commit 038e0ca

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

13/umbraco-deploy/deployment-workflow/import-on-startup.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ internal sealed class DeployImportOnStartupComposer : IComposer
2929
{
3030
public void Compose(IUmbracoBuilder builder)
3131
=> builder.DeployArtifactImportOnStartupProviders()
32-
.Append<PhysicalDirectoryArtifactImportOnStartupProvider>();
32+
.Append<PhysicalDirectoryArtifactImportOnStartupProvider>();
3333

3434
private sealed class PhysicalDirectoryArtifactImportOnStartupProvider : IArtifactImportOnStartupProvider
3535
{
@@ -55,14 +55,14 @@ internal sealed class DeployImportOnStartupComposer : IComposer
5555

5656
_logger.LogInformation("Imported Umbraco content and/or schema import at startup from directory {FilePath} with status: {OperationStatus}.", _artifactsPath, attempt.Result);
5757

58-
return attempt;
59-
}
58+
if (attempt.Success)
59+
{
60+
Directory.Delete(_artifactsPath, true);
6061

61-
public Task OnImportCompletedAsync()
62-
{
63-
Directory.Delete(_artifactsPath, true);
62+
_logger.LogInformation("Deleted physical directory after successful import on startup {FilePath}.", _artifactsPath);
63+
}
6464

65-
return Task.CompletedTask;
65+
return attempt;
6666
}
6767
}
6868
}

14/umbraco-deploy/deployment-workflow/import-on-startup.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ internal sealed class DeployImportOnStartupComposer : IComposer
2929
{
3030
public void Compose(IUmbracoBuilder builder)
3131
=> builder.DeployArtifactImportOnStartupProviders()
32-
.Append<PhysicalDirectoryArtifactImportOnStartupProvider>();
32+
.Append<PhysicalDirectoryArtifactImportOnStartupProvider>();
3333

3434
private sealed class PhysicalDirectoryArtifactImportOnStartupProvider : IArtifactImportOnStartupProvider
3535
{
@@ -55,14 +55,14 @@ internal sealed class DeployImportOnStartupComposer : IComposer
5555

5656
_logger.LogInformation("Imported Umbraco content and/or schema import at startup from directory {FilePath} with status: {OperationStatus}.", _artifactsPath, attempt.Result);
5757

58-
return attempt;
59-
}
58+
if (attempt.Success)
59+
{
60+
Directory.Delete(_artifactsPath, true);
6061

61-
public Task OnImportCompletedAsync()
62-
{
63-
Directory.Delete(_artifactsPath, true);
62+
_logger.LogInformation("Deleted physical directory after successful import on startup {FilePath}.", _artifactsPath);
63+
}
6464

65-
return Task.CompletedTask;
65+
return attempt;
6666
}
6767
}
6868
}

15/umbraco-deploy/deployment-workflow/import-on-startup.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ internal sealed class DeployImportOnStartupComposer : IComposer
2929
{
3030
public void Compose(IUmbracoBuilder builder)
3131
=> builder.DeployArtifactImportOnStartupProviders()
32-
.Append<PhysicalDirectoryArtifactImportOnStartupProvider>();
32+
.Append<PhysicalDirectoryArtifactImportOnStartupProvider>();
3333

3434
private sealed class PhysicalDirectoryArtifactImportOnStartupProvider : IArtifactImportOnStartupProvider
3535
{
@@ -55,14 +55,14 @@ internal sealed class DeployImportOnStartupComposer : IComposer
5555

5656
_logger.LogInformation("Imported Umbraco content and/or schema import at startup from directory {FilePath} with status: {OperationStatus}.", _artifactsPath, attempt.Result);
5757

58-
return attempt;
59-
}
58+
if (attempt.Success)
59+
{
60+
Directory.Delete(_artifactsPath, true);
6061

61-
public Task OnImportCompletedAsync()
62-
{
63-
Directory.Delete(_artifactsPath, true);
62+
_logger.LogInformation("Deleted physical directory after successful import on startup {FilePath}.", _artifactsPath);
63+
}
6464

65-
return Task.CompletedTask;
65+
return attempt;
6666
}
6767
}
6868
}

0 commit comments

Comments
 (0)