mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-04 08:00:16 -04:00
WIP saving
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
using ModernKeePassLib.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
@@ -610,7 +610,7 @@ namespace ModernKeePassLib
|
||||
/// it has been opened from.
|
||||
/// </summary>
|
||||
/// <param name="slLogger">Logger that recieves status information.</param>
|
||||
public void Save(IStatusLogger slLogger)
|
||||
public async void Save(IStatusLogger slLogger)
|
||||
{
|
||||
Debug.Assert(ValidateUuidUniqueness());
|
||||
|
||||
@@ -620,7 +620,7 @@ namespace ModernKeePassLib
|
||||
{
|
||||
FileTransactionEx ft = new FileTransactionEx(m_ioSource,
|
||||
m_bUseFileTransactions);
|
||||
Stream s = ft.OpenWrite();
|
||||
Stream s = await ft.OpenWrite();
|
||||
|
||||
Kdb4File kdb = new Kdb4File(this);
|
||||
kdb.Save(s, null, Kdb4Format.Default, slLogger);
|
||||
@@ -631,6 +631,8 @@ namespace ModernKeePassLib
|
||||
m_pbHashOfFileOnDisk = kdb.HashOfFileOnDisk;
|
||||
Debug.Assert(m_pbHashOfFileOnDisk != null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{ }
|
||||
finally { if(fl != null) fl.Dispose(); }
|
||||
|
||||
m_bModified = false;
|
||||
|
@@ -22,6 +22,7 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
// Bert TODO: For now, remove the accesscontrol from this class.
|
||||
// In WinRT, the security of file has changed, and something could potentially be done
|
||||
@@ -70,7 +71,7 @@ namespace ModernKeePassLib.Serialization
|
||||
else m_iocTemp = m_iocBase;
|
||||
}
|
||||
|
||||
public Stream OpenWrite()
|
||||
public async Task<Stream> OpenWrite()
|
||||
{
|
||||
if(!m_bTransacted) m_bMadeUnhidden = UrlUtil.UnhideFile(m_iocTemp.Path);
|
||||
else // m_bTransacted
|
||||
@@ -79,7 +80,7 @@ namespace ModernKeePassLib.Serialization
|
||||
catch(Exception) { }
|
||||
}
|
||||
|
||||
return IOConnection.OpenWrite(m_iocTemp);
|
||||
return await IOConnection.OpenWrite(m_iocTemp);
|
||||
}
|
||||
|
||||
public void CommitWrite()
|
||||
|
@@ -281,18 +281,24 @@ namespace ModernKeePassLib.Serialization
|
||||
return CreateWebClient(ioc).OpenWrite(uri);
|
||||
}
|
||||
#else
|
||||
public static Stream OpenWrite(IOConnectionInfo ioc)
|
||||
public async static Task<Stream> OpenWrite(IOConnectionInfo ioc)
|
||||
{
|
||||
return OpenWriteLocal(ioc);
|
||||
return await OpenWriteLocal(ioc);
|
||||
}
|
||||
#endif
|
||||
|
||||
private static Stream OpenWriteLocal(IOConnectionInfo ioc)
|
||||
private async static Task<Stream> OpenWriteLocal(IOConnectionInfo ioc)
|
||||
{
|
||||
Debug.Assert(false, "Not implemented yet");
|
||||
return null;
|
||||
// return new FileStream(ioc.Path, FileMode.Create, FileAccess.Write,
|
||||
// FileShare.None);
|
||||
try
|
||||
{
|
||||
IRandomAccessStream stream = await ioc.StorageFile.OpenAsync(FileAccessMode.ReadWrite);
|
||||
return stream.AsStream();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.Assert(false, ex.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool FileExists(IOConnectionInfo ioc)
|
||||
|
Reference in New Issue
Block a user