Skip to content

Commit 20a255a

Browse files
committed
Fix hardcoded file path
1 parent 4cc9080 commit 20a255a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Diff for: source/jaindb/Startup.cs

+1
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ private void OnStartup()
266266
}
267267
catch(Exception ex)
268268
{
269+
Debug.WriteLine(ex.Message);
269270
jDB.UseRethinkDB = false;
270271
jDB.UseFileStore = true;
271272
}

Diff for: source/jaindb/jaindb.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,16 @@ public static bool WriteHash(string Hash, string Data, string Collection)
284284
}
285285
}
286286

287-
if (UseFileStore)
287+
if (UseFileStore) //in case if Redis and FileStore
288288
{
289+
if (!Directory.Exists(Path.Combine(FilePath, Collection)))
290+
Directory.CreateDirectory(Path.Combine(FilePath, Collection));
289291

292+
if (!File.Exists(Path.Combine(FilePath, Collection, Hash + ".json"))) //We do not have to create the same hash file twice...
290293
{
291294
lock (locker) //only one write operation
292295
{
296+
File.WriteAllText(Path.Combine(FilePath, Collection, Hash + ".json"), Data);
293297
}
294298
}
295299
}
@@ -492,6 +496,7 @@ public static bool WriteHash(string Hash, string Data, string Collection)
492496
}
493497
catch (Exception ex)
494498
{
499+
Debug.WriteLine(ex.Message);
495500
if (!Directory.Exists(Path.Combine(FilePath, Collection)))
496501
Directory.CreateDirectory(Path.Combine(FilePath, Collection));
497502

@@ -1146,7 +1151,7 @@ public static JObject GetFull(string DeviceID, int Index = -1, string blockType
11461151
if (Index == -1)
11471152
{
11481153
//Cache Full
1149-
WriteHashAsync(DeviceID, oInv.ToString(), "_full");
1154+
WriteHashAsync(DeviceID, oInv.ToString(), "_full").ConfigureAwait(false);
11501155
}
11511156

11521157
/*var cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromSeconds(60)); //cache full for 60s

0 commit comments

Comments
 (0)