Revision 3c76f045 trunk/Pithos.Core/FileState.cs
b/trunk/Pithos.Core/FileState.cs | ||
---|---|---|
59 | 59 |
{ |
60 | 60 |
private static readonly ILog Log = LogManager.GetLogger("FileState"); |
61 | 61 |
|
62 |
private string _filePath; |
|
63 | 62 |
private IList<FileTag> _tags = new List<FileTag>(); |
64 | 63 |
|
65 | 64 |
[PrimaryKey(PrimaryKeyType.Guid)] |
66 | 65 |
public Guid Id { get; set; } |
67 | 66 |
|
67 |
|
|
68 | 68 |
[Property(Unique = true, UniqueKey = "IX_FileState_FilePath")] |
69 |
public string FilePath |
|
70 |
{ |
|
71 |
get { return _filePath; } |
|
72 |
set { _filePath = value.ToLower(); } |
|
73 |
} |
|
69 |
public string FilePath { get; set; } |
|
74 | 70 |
|
75 | 71 |
[Property] |
76 | 72 |
public FileOverlayStatus OverlayStatus { get; set; } |
... | ... | |
98 | 94 |
[Property] |
99 | 95 |
public bool ShareWrite { get; set; } |
100 | 96 |
|
97 |
[Property] |
|
98 |
public bool IsFolder{ get; set; } |
|
101 | 99 |
|
102 | 100 |
[HasMany(Cascade = ManyRelationCascadeEnum.AllDeleteOrphan, Lazy = true, Inverse = true)] |
103 | 101 |
public IList<FileTag> Tags |
... | ... | |
117 | 115 |
|
118 | 116 |
|
119 | 117 |
|
120 |
return Queryable.FirstOrDefault(s => s.FilePath == absolutePath.ToLower());
|
|
118 |
return Queryable.FirstOrDefault(s => s.FilePath == absolutePath); |
|
121 | 119 |
} |
122 | 120 |
catch (Exception ex) |
123 | 121 |
{ |
... | ... | |
138 | 136 |
{ |
139 | 137 |
const string hqlDelete = "delete FileState where FilePath = :path"; |
140 | 138 |
var deletedEntities = session.CreateQuery(hqlDelete) |
141 |
.SetString("path", absolutePath.ToLower())
|
|
139 |
.SetString("path", absolutePath) |
|
142 | 140 |
.ExecuteUpdate(); |
143 | 141 |
return deletedEntities; |
144 | 142 |
}, null); |
... | ... | |
153 | 151 |
|
154 | 152 |
ExecuteWithRetry((session, instance) => |
155 | 153 |
{ |
156 |
const string hqlUpdate = "update FileState set FileStatus= :status where FilePath = :path ";
|
|
154 |
const string hqlUpdate = "update FileState set FileStatus= :status where FilePath = :path "; |
|
157 | 155 |
var updatedEntities = session.CreateQuery(hqlUpdate) |
158 |
.SetString("path", absolutePath.ToLower())
|
|
156 |
.SetString("path", absolutePath) |
|
159 | 157 |
.SetEnum("status", newStatus) |
160 | 158 |
.ExecuteUpdate(); |
161 | 159 |
if (updatedEntities == 0) |
162 | 160 |
{ |
163 | 161 |
var newState = new FileState |
164 | 162 |
{ |
165 |
FilePath = absolutePath.ToLower(),
|
|
163 |
FilePath = absolutePath, |
|
166 | 164 |
Id = Guid.NewGuid(), |
167 |
FileStatus = newStatus |
|
165 |
FileStatus = newStatus, |
|
166 |
IsFolder=Directory.Exists(absolutePath) |
|
168 | 167 |
}; |
169 | 168 |
newState.CreateAndFlush(); |
170 | 169 |
} |
... | ... | |
182 | 181 |
ExecuteWithRetry((session, instance) => |
183 | 182 |
{ |
184 | 183 |
const string hqlUpdate = |
185 |
"update FileState set OverlayStatus= :status where FilePath = :path ";
|
|
186 |
var updatedEntities = session.CreateQuery(hqlUpdate) |
|
187 |
.SetString("path", absolutePath.ToLower())
|
|
188 |
.SetEnum("status", newStatus) |
|
184 |
"update FileState set OverlayStatus= :status where FilePath = :path "; |
|
185 |
var updatedEntities = session.CreateQuery(hqlUpdate)
|
|
186 |
.SetString("path", absolutePath) |
|
187 |
.SetEnum("status", newStatus)
|
|
189 | 188 |
.ExecuteUpdate(); |
190 | 189 |
if (updatedEntities == 0) |
191 | 190 |
{ |
... | ... | |
193 | 192 |
{ |
194 | 193 |
FilePath = absolutePath, |
195 | 194 |
Id = Guid.NewGuid(), |
196 |
OverlayStatus = newStatus |
|
195 |
OverlayStatus = newStatus, |
|
196 |
IsFolder=Directory.Exists(absolutePath) |
|
197 | 197 |
}; |
198 | 198 |
newState.CreateAndFlush(); |
199 | 199 |
} |
... | ... | |
214 | 214 |
const string hqlUpdate = |
215 | 215 |
"update FileState set OverlayStatus= :overlayStatus, FileStatus= :fileStatus where FilePath = :path "; |
216 | 216 |
var updatedEntities = session.CreateQuery(hqlUpdate) |
217 |
.SetString("path", absolutePath.ToLower())
|
|
217 |
.SetString("path", absolutePath) |
|
218 | 218 |
.SetEnum("fileStatus", fileStatus) |
219 | 219 |
.SetEnum("overlayStatus", overlayStatus) |
220 | 220 |
.ExecuteUpdate(); |
... | ... | |
236 | 236 |
const string hqlUpdate = |
237 | 237 |
"update FileState set FileStatus= :fileStatus where FilePath = :path "; |
238 | 238 |
var updatedEntities = session.CreateQuery(hqlUpdate) |
239 |
.SetString("path", absolutePath.ToLower())
|
|
239 |
.SetString("path", absolutePath) |
|
240 | 240 |
.SetEnum("fileStatus", fileStatus) |
241 | 241 |
.ExecuteUpdate(); |
242 | 242 |
return updatedEntities; |
... | ... | |
254 | 254 |
ExecuteWithRetry((session, instance) => |
255 | 255 |
{ |
256 | 256 |
const string hqlUpdate = |
257 |
"update FileState set FilePath= :newPath where FilePath = :oldPath ";
|
|
257 |
"update FileState set FilePath= :newPath where FilePath = :oldPath "; |
|
258 | 258 |
var updatedEntities = session.CreateQuery(hqlUpdate) |
259 |
.SetString("oldPath", oldPath.ToLower())
|
|
260 |
.SetString("newPath", newPath.ToLower())
|
|
259 |
.SetString("oldPath", oldPath) |
|
260 |
.SetString("newPath", newPath) |
|
261 | 261 |
.ExecuteUpdate(); |
262 | 262 |
return updatedEntities; |
263 | 263 |
}, null); |
... | ... | |
287 | 287 |
|
288 | 288 |
ExecuteWithRetry((session, instance) => |
289 | 289 |
{ |
290 |
const string hqlUpdate = "update FileState set Checksum= :checksum where FilePath = :path ";
|
|
290 |
const string hqlUpdate = "update FileState set Checksum= :checksum where FilePath = :path "; |
|
291 | 291 |
var updatedEntities = session.CreateQuery(hqlUpdate) |
292 |
.SetString("path", absolutePath.ToLower())
|
|
292 |
.SetString("path", absolutePath) |
|
293 | 293 |
.SetString("checksum", checksum) |
294 | 294 |
.ExecuteUpdate(); |
295 | 295 |
return updatedEntities; |
... | ... | |
320 | 320 |
const string hqlUpdate = |
321 | 321 |
"update FileState set FilePath = replace(FilePath,:oldPath,:newPath) where FilePath like :oldPath || '%' "; |
322 | 322 |
var renames = session.CreateQuery(hqlUpdate) |
323 |
.SetString("oldPath", oldPath.ToLower())
|
|
324 |
.SetString("newPath", newPath.ToLower())
|
|
323 |
.SetString("oldPath", oldPath) |
|
324 |
.SetString("newPath", newPath) |
|
325 | 325 |
.ExecuteUpdate(); |
326 | 326 |
return renames; |
327 | 327 |
}, null); |
... | ... | |
338 | 338 |
|
339 | 339 |
var fileState = new FileState |
340 | 340 |
{ |
341 |
FilePath = filePath.ToLower(),
|
|
341 |
FilePath = filePath, |
|
342 | 342 |
OverlayStatus = FileOverlayStatus.Unversioned, |
343 | 343 |
FileStatus = FileStatus.Created, |
344 | 344 |
Id = Guid.NewGuid() |
Also available in: Unified diff