Skip to content

Update disk space based on file manager action#1576

Closed
bdgreenweb wants to merge 1 commit intousmannasir:stablefrom
bdgreenweb:patch-7
Closed

Update disk space based on file manager action#1576
bdgreenweb wants to merge 1 commit intousmannasir:stablefrom
bdgreenweb:patch-7

Conversation

@bdgreenweb
Copy link
Contributor

update disk space whenever someone perform any of the following actions:

  • create new file
  • delete file or folder
  • upload file
  • compress or extract
  • copy or move

update disk space whenever someone perform any of the following actions:
- create new file
- delete file or folder
- upload file
- compress or extract 
- copy or move
@bdgreenweb bdgreenweb mentioned this pull request Oct 7, 2025
@usmannasir
Copy link
Owner

This can potentially slow down file operations.

@bdgreenweb
Copy link
Contributor Author

This can potentially slow down file operations.

This feature is essential from both a user perspective and a provider support standpoint.
Currently, when users delete files, their disk usage doesn't reflect the change immediately. This often leads to confusion—users see no difference in disk usage and assume something is broken. As a result, they raise support tickets, creating unnecessary overhead for the hosting provider.
Additionally, users can continue uploading files even after exceeding their disk quota, simply because they aren’t aware they’ve already gone over the limit. For instance, one of our users with a 1GB quota was able to upload over 5GB of files without realizing it.
We've tested this functionality on a large site (30GB+), and although the operation takes slightly longer, it's still very sustainable. In practice, users don’t frequently upload or modify files via the file manager. Moreover, our implementation is even faster than what's currently seen in cPanel or DirectAdmin. We can improve it slightly to make it faster like using a file which will contain individual directory size and only calculate affected directory size by the last operation. This will be faster and better. Cpanel is using this system. It will be possible to show individual directory wise size in panel by implementing it.

usmannasir added a commit that referenced this pull request Oct 8, 2025
This commit implements an improved version of PRs #1575 and #1576 from @bdgreenweb
with critical performance optimizations.

## Background
The original PRs (#1575, #1576) proposed real-time disk usage tracking for file
manager operations. While the feature was valuable for improving user awareness of
disk quotas, there were several concerns:

1. **Performance Impact**: Original implementation used synchronous `executioner()`
   calls that would block file operations until disk calculation completed
2. **Target Branch Issues**: PRs were submitted to the stable branch instead of
   development branch, which could introduce instability
3. **Blocking Operations**: Each file operation would wait for disk usage
   recalculation, potentially causing noticeable delays

## Implementation Changes

### filemanager/filemanager.py
- Added disk usage updates to 9 file operation methods:
  - createNewFile() - After file creation
  - createNewFolder() - After folder creation
  - deleteFolderOrFile() - After deletion (both permanent and trash)
  - restore() - After restoring from trash
  - copy() - After copying files/folders
  - move() - After moving files/folders
  - upload() - After file uploads
  - extract() - After extracting archives
  - compress() - After creating archives

### plogical/IncScheduler.py
- Added CalculateAndUpdateDiskUsageDomain() function for domain-specific updates
- Added command-line argument handler for UpdateDiskUsageForceDomain
- Calculates disk usage for websites, email accounts, and bandwidth

## Key Improvements Over Original PRs

1. **Asynchronous Execution**: Uses `popenExecutioner()` instead of `executioner()`
   - File operations return immediately without waiting
   - Disk usage updates happen in background threads
   - Zero performance impact on user operations

2. **Selective Updates**: Only updates the specific domain affected by the operation
   rather than all domains system-wide

3. **Proper Branch Targeting**: Applied to development branch (v2.5.5-dev) for
   proper testing before stable release

## Benefits
- Real-time disk usage tracking as requested
- No performance degradation
- Users immediately aware of quota usage
- Prevents accidental quota violations
- Better than competitors (cPanel/DirectAdmin) in responsiveness

## Acknowledgments
Thank you @bdgreenweb for the original implementation idea and PRs #1575/#1576.
While we couldn't merge them directly due to the performance and stability concerns
mentioned above, your contribution highlighted an important feature gap. This
implementation preserves your core functionality while addressing the performance
concerns through asynchronous execution.

This will definitely help organizations track disk usage more effectively without
sacrificing file manager performance.
@master3395
Copy link
Collaborator

Already implemented in 4bedb9c

@master3395 master3395 closed this Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants