diff options
author | Lluis Sanchez <llsan@microsoft.com> | 2017-02-21 17:52:06 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-21 17:52:06 +0300 |
commit | 5b1979439bb1c13f2c347f18fc89dff6b1e1aa2c (patch) | |
tree | 0fa7da2352bf55ccc4187501876172d188200d0d | |
parent | eea24ae654e8e31584b2b086b56e368456ddd86a (diff) | |
parent | 22772aed65a51ad97692c63c8fe0e8b7ea718b1d (diff) |
Merge pull request #51 from directhex/explain-magic-numbers
Add some explanation behind 9b673202536788b2a2b98e4882e1a30d196bc897
-rw-r--r-- | Mono.Addins/Mono.Addins.Database/FileDatabase.cs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Mono.Addins/Mono.Addins.Database/FileDatabase.cs b/Mono.Addins/Mono.Addins.Database/FileDatabase.cs index ce00ea6..3fc88a6 100644 --- a/Mono.Addins/Mono.Addins.Database/FileDatabase.cs +++ b/Mono.Addins/Mono.Addins.Database/FileDatabase.cs @@ -451,6 +451,12 @@ namespace Mono.Addins.Database string GetFileKey (string directory, string sharedFileName, string objectId) { + // We have two magic numbers here. 240 is a "room to spare" number based on 255, + // the Windows MAX_PATH length for the full path of a file on disk. Then 130 is + // a "room to spare" number based on 143-"ish", the maximum filename length for + // files stored on eCryptFS on Linux. 240 relates to the complete path + // (including the directory structure), and 130 is just the filename, so we pick + // whichever is the smaller of those two numbers when truncating. int avlen = System.Math.Min (System.Math.Max (240 - directory.Length, 10), 130); string name = sharedFileName + "_" + Util.GetStringHashCode (objectId).ToString ("x"); if (name.Length > avlen) |