Skip to content

Adding a widget that displays the current disc usage to the home page#93

Open
Mactory wants to merge 4 commits intoprojectsend:masterfrom
NB-Dev:disk_usage
Open

Adding a widget that displays the current disc usage to the home page#93
Mactory wants to merge 4 commits intoprojectsend:masterfrom
NB-Dev:disk_usage

Conversation

@Mactory
Copy link

@Mactory Mactory commented Mar 28, 2016

No description provided.

@lenamtl
Copy link
Collaborator

lenamtl commented Mar 28, 2016

Hi,

How this is work, is if checking everytime the page refresh?

Have you test it with big files, lots of file with lots of users connected at the same time?

I'm just wondering if it can take a lot of resource to check that info.
Maybe this is less consuming if it is on demand like click on a button to check or a cronjob that does that once a day. Or maybe this could be a settings, so admin can enable or disable the function...

@Mactory
Copy link
Author

Mactory commented Mar 28, 2016

Hi,

Yes, it is checking each time the page is loaded.
I thought about alternatives but decided for this solution as it concurs with the way the size calculation is solved in the "files" view. There the size of each file is calculated as the table is displayed. Therefore I also calculate the size of all files in the file folder on demand.

I do agree with you, that this could be problematic for large file bases, I did not test this though. On the pro side, i can state, that the file size calculation is done with the help of operating system tools (by usage of the same function as in the file view) which makes it quick.

Possible solutions:

  1. As you stated, this could be done on demand (e.g. by clicking a button) which reduces the load. I would not prefer this solution as it seems better to me to solve the problem in another way.
  2. En- / Disabling the feature does not solve the problem in my opinion, as there might be users that want to see the used file size but need this to be calculated quickly.
  3. Calculate the size in a cron job: Small system load but the file size is updated to seldom to be of real use. A frequend cron job on the other hand could potentially calculate the same file sizes over and over.
  4. Use system tools to calculate the size of the whole folder instead of sum the sizes of each file. I have no idea how this solution would perform. The pro side is that we would always have the most recent sizes of all files in the folder.
  5. Use the database to store the file size information, then retrieve the used space by summing the column in the database. The file sizes would need to be calculated on upload / add to the project and then stored in the database. This would seem like the best solution for the project as it is not OS dependent but poses some problems: If files are changed, this change needs to be reflected in the database. Files that were uploaded to the folder via FTP would not be added to the sum. The main problem with this would be the side path via FTP, because all actions that are done via the website could be registered and the sizes in the db updated accordingly.

I would actually prefer solution 5, as it seems the correct way to me. I would propose to ignore files that are in the uploaded folder but not yet added to the project. The remaining problem would be that files could be changed via FTP. For this I would propose to synchronize the size of a file with the stored value in the database at download time.

To implement this myself, I would, however, need some pointers as where to start. Could you point me to the place where I could add the "migration" of the database to add the file size column? I usually program for django in Python, so I'm not using PHP on a daily basis.

@lenamtl
Copy link
Collaborator

lenamtl commented Apr 26, 2016

I agree with you about solution 5.
Not sure about the sync size on download.

Tim Schneider added 3 commits August 19, 2016 18:49
@lenamtl lenamtl mentioned this pull request Nov 24, 2016
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.

2 participants