mirror of
https://github.com/sismics/docs.git
synced 2024-12-22 19:33:47 +01:00
Quota updates are not polluting the audit log anymore
This commit is contained in:
parent
332de409b8
commit
5f82752416
@ -110,6 +110,26 @@ public class UserDao {
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a user's quota.
|
||||
*
|
||||
* @param user User to update
|
||||
* @return Updated user
|
||||
*/
|
||||
public User updateQuota(User user) {
|
||||
EntityManager em = ThreadLocalContext.get().getEntityManager();
|
||||
|
||||
// Get the user
|
||||
Query q = em.createQuery("select u from User u where u.id = :id and u.deleteDate is null");
|
||||
q.setParameter("id", user.getId());
|
||||
User userFromDb = (User) q.getSingleResult();
|
||||
|
||||
// Update the user
|
||||
userFromDb.setStorageQuota(user.getStorageQuota());
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the user password.
|
||||
*
|
||||
|
@ -304,7 +304,7 @@ public class AppResource extends BaseResource {
|
||||
// Save all users
|
||||
for (User user : userMap.values()) {
|
||||
if (user.getDeleteDate() == null) {
|
||||
userDao.update(user);
|
||||
userDao.updateQuota(user);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ public class FileResource extends BaseResource {
|
||||
|
||||
// Update the user quota
|
||||
user.setStorageCurrent(user.getStorageCurrent() + fileData.length);
|
||||
userDao.update(user);
|
||||
userDao.updateQuota(user);
|
||||
|
||||
// Raise a new file created event if we have a document
|
||||
if (documentId != null) {
|
||||
@ -369,7 +369,7 @@ public class FileResource extends BaseResource {
|
||||
java.nio.file.Path storedFile = DirectoryUtil.getStorageDirectory().resolve(id);
|
||||
try {
|
||||
user.setStorageCurrent(user.getStorageCurrent() - Files.size(storedFile));
|
||||
userDao.update(user);
|
||||
userDao.updateQuota(user);
|
||||
} catch (IOException e) {
|
||||
// The file doesn't exists on disk, which is weird, but not fatal
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user