2017-05-12 14:49:44 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Core.IO
|
|
|
|
|
|
{
|
2018-11-19 14:40:59 +01:00
|
|
|
|
// shadow filesystems is definitively ... too convoluted
|
|
|
|
|
|
|
2017-05-12 14:49:44 +02:00
|
|
|
|
internal class ShadowFileSystems : ICompletable
|
|
|
|
|
|
{
|
2018-11-19 14:40:59 +01:00
|
|
|
|
private readonly FileSystems _fileSystems;
|
2017-05-12 14:49:44 +02:00
|
|
|
|
private bool _completed;
|
|
|
|
|
|
|
2018-10-26 15:06:53 +02:00
|
|
|
|
// invoked by the filesystems when shadowing
|
2019-02-20 14:10:15 +01:00
|
|
|
|
public ShadowFileSystems(FileSystems fileSystems, string id)
|
2017-05-12 14:49:44 +02:00
|
|
|
|
{
|
2018-11-19 14:40:59 +01:00
|
|
|
|
_fileSystems = fileSystems;
|
|
|
|
|
|
Id = id;
|
2017-05-12 14:49:44 +02:00
|
|
|
|
|
2018-11-19 14:40:59 +01:00
|
|
|
|
_fileSystems.BeginShadow(id);
|
2017-05-12 14:49:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-11-19 14:40:59 +01:00
|
|
|
|
// for tests
|
2019-02-20 14:10:15 +01:00
|
|
|
|
public string Id { get; }
|
2018-11-19 14:40:59 +01:00
|
|
|
|
|
2018-10-26 15:06:53 +02:00
|
|
|
|
// invoked by the scope when exiting, if completed
|
2017-05-12 14:49:44 +02:00
|
|
|
|
public void Complete()
|
|
|
|
|
|
{
|
|
|
|
|
|
_completed = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-10-26 15:06:53 +02:00
|
|
|
|
// invoked by the scope when exiting
|
2017-05-12 14:49:44 +02:00
|
|
|
|
public void Dispose()
|
|
|
|
|
|
{
|
2018-11-19 14:40:59 +01:00
|
|
|
|
_fileSystems.EndShadow(Id, _completed);
|
2017-05-12 14:49:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|