It is currently March 28th, 2024, 2:45 pm

Detect Ongoing File/Folder Transfer?

Get help with creating, editing & fixing problems with skins
Post Reply
User avatar
StArL0rd84
Posts: 424
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Detect Ongoing File/Folder Transfer?

Post by StArL0rd84 »

Hi all. Been a While since i visited these forums.
Been quite busy, but now i've got time for Rainmeter again ^^.

I have made a backup skin and when you click the icon it backups a folder to a predetermined location.
It works quite well.
But in order for it to tie in with the design language of the rest of the suite, i'd like the icon to animate.

So far i have managed to make it change color and shape when the original folder and destination folder does not match in size.

But the icon should really only change when the mouse is over it or there is an ongoing transfer happening.
bk.png
So My question to you would be:
Is there ANY way of measuring this?

What i have to work with:
Folder name.
Origin folder directory.
Destination folder directory.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Detect Ongoing File/Folder Transfer?

Post by balala »

You should post your code, or if it uses resources (and I think it does), like images, some lua scripts or third party addons, it would be even better to pack the whole config and upload it. Without this, is very hard to give any advice.
User avatar
StArL0rd84
Posts: 424
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Re: Detect Ongoing File/Folder Transfer?

Post by StArL0rd84 »

balala wrote:You should post your code, or if it uses resources (and I think it does), like images, some lua scripts or third party addons, it would be even better to pack the whole config and upload it. Without this, is very hard to give any advice.
BackupExample_0.1.rmskin
(117.37 KiB) Downloaded 20 times
User avatar
StArL0rd84
Posts: 424
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Re: Detect Ongoing File/Folder Transfer?

Post by StArL0rd84 »

What i ultimately need is a 0 or a 1 depending if a file transfer window is open.
Maybe something that "listens" for a transfer of a specific folder or file that i know the name of.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Detect Ongoing File/Folder Transfer?

Post by balala »

StArL0rd84 wrote:What i ultimately need is a 0 or a 1 depending if a file transfer window is open.
Hard. To be honest I don't see a way to do this, eventually just with a third party addon. But I can't recommend one now.
On the other hand there is a possible partial solution. This uses the PerfMon plugin, which is used to measure the transfer rate to a logical disk. Problem is that you can't (or at least I didn't find yet how to) set a folder, which would be watched. As far as I know just a disk can be. This means that if something is copied to the disk, doesn't matter in which folder it is, the skin will show the same result.
So, according to this (partial) solution, you should add the following measure to the code:

Code: Select all

[MeasureDiskWrite]
Measure=Plugin
Plugin=PerfMon
PerfMonObject=LogicalDisk
PerfMonCounter=Disk Write Bytes/sec
PerfMonInstance=F:
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!SetVariable Transfer "0"]
IfFalseAction=[!SetVariable Transfer "1"]
The value of the transfer variable is 1 while the data are copied to the appropriate disk (in this case to the F: disk, set by the PerfMonInstance option), because the measure returns a value greater then 0, respectively 0, if data are not copied.
The problem: if data are copied / written to the disk, doesn't matter if they are through your skin or any other way, or in which folder they are, the variable will be set anyway to 1.
As I said above, probably a better solution would be to find a proper third party app.
Sorry I can't help more. Maybe someone will be more inteligent and will find a better solution.
User avatar
StArL0rd84
Posts: 424
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Re: Detect Ongoing File/Folder Transfer?

Post by StArL0rd84 »

Actually your perfmon code worked great for my personal situation since i am writing to a USB stick that does not see any traffic but the backup process.
But yeah, still need another solution since i plan to release my suite some day.
And i do foresee an issue if for example the backup location is in the C drive, since that drive are busy all the time.
Turns into a hard drive activity case light lol.

Thank you for your time and help balala.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Detect Ongoing File/Folder Transfer?

Post by balala »

StArL0rd84 wrote:Actually your perfmon code worked great for my personal situation since i am writing to a USB stick that does not see any traffic but the backup process.
But yeah, still need another solution since i plan to release my suite some day.
And i do foresee an issue if for example the backup location is in the C drive, since that drive are busy all the time.
Turns into a hard drive activity case light lol.

Thank you for your time and help balala.
For nothing. My solution definitely is not good at all, if you're planning to use the C: for backup location. I do know the limits of that solution, but couldn't find a better one. At least yet...
Matth
Posts: 54
Joined: May 17th, 2017, 8:43 am

Re: Detect Ongoing File/Folder Transfer?

Post by Matth »

What if you check the sizes of both directories and compare them. If there's a difference, you'd need to do the backup.

Now if the size diff. changes (i.e. gets smaller) you can probably assume that a file transfer is going on. Though it could also be, if some of the source files gets deleted or decreases in size. Maybe if the change has to be detected more than once consecutively?

I guess it would be a very expensive solution though.
User avatar
StArL0rd84
Posts: 424
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Re: Detect Ongoing File/Folder Transfer?

Post by StArL0rd84 »

Tnx for the suggestion matth. But I already tried counting the files of both folders to achieve what I want, but it works to slowly. I guess I could explore it further though.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Detect Ongoing File/Folder Transfer?

Post by balala »

To be honest, a such task is not what Rainmeter was made for. I don't say it can't be done, but Rainmeter has other purposes.
Post Reply