Purge time

Sep 23, 2011 at 11:39 AM
Edited Sep 23, 2011 at 11:42 AM

I've just started working with this component and found my files were being purged as they were uploading.  I made the change below:

internal void PurgeTempFiles(string folder)
{
	if (this.PurgeInterval == 0)
		return;
	foreach (var file in Directory.GetFiles(folder, "*.*", SearchOption.TopDirectoryOnly))
	{
		FileInfo fi = new FileInfo(file);
		//OLD LINE: int diff = DateTime.UtcNow.Subtract(fi.LastAccessTimeUtc).Minutes;
		//NEW LINE:
        		int diff = Convert.ToInt32(DateTime.UtcNow.Subtract(fi.LastWriteTimeUtc).TotalMinutes);
		if (diff > this.PurgeInterval)
			fi.Delete();
	}
}

On my dev machine the LastAccessTime was set to the days date with 0hrs 0mins.  Possibly because it was the first chunk and hadn't been accessed yet?

Also 'Minutes' can be zero when looking at a file 1 hour and 30 seconds old, so 'TotalMinuets' makes more sense.

Can anyone verify these changes and if needed role in to the src?

Matt


Sep 23, 2011 at 7:10 PM

Hey Matt,

Changing the Minutes to TotalMinutes won't have any effect unless your uploads take longer than an hour.

Also, if your files are being purged too soon, you should change the purge interval to your longest expected individual file upload duration.

So if your longest individual file upload is expected to take 30 minutes then you should set the purge interval to 35 minutes. It's defaulted to 5 minutes.

Sep 23, 2011 at 8:18 PM
Edited Sep 23, 2011 at 8:18 PM

To support long uploads (uploads that take more than an hour), I'm going to change from Minutes to TotalMinutes. This is to align with the fact that the purge interval allows up to 11 hours and will provide support for super long uploads where the dialog is not being displayed to a user as an upload where a user is monitoring the upload progress would not want to wait an hour or more. This enables a scenario where you could have an upload process runnning in the background and then the user could periodically come back and check. Although until Silverlight 5 is released, this is not recommended as the network calls all happen on the main thread.

Sep 23, 2011 at 8:22 PM

Ok, Glad to help.

Have you experienced issues with LastAccessTime returning midnight the first time purge is called on a file.  I did and it was then comparing it with the current time and deciding the file was old.  This meant the file in progress was deleted and an exception thrown.  So I changed it to LastWriteTime which had the correct time in it.

Matt

Sep 23, 2011 at 8:23 PM

No this is the first I've heard of the LastAccessTime returning an  earlier Time. What is your OS info?

Sep 23, 2011 at 8:33 PM
Edited Sep 23, 2011 at 8:38 PM

XP Pro 2002 SP3 on Intel

see the watch variables in this image: https://picasaweb.google.com/lh/photo/20av5cJXl-WzqshKCJUKYw?feat=directlink

and the temp files properties: https://picasaweb.google.com/lh/photo/8r_0smifkOpFxeyZ9oBNXQ?feat=directlink

notice the time missing of the access property!

Sep 23, 2011 at 8:46 PM

Can I see your CreateNewFile() code?

Sep 23, 2011 at 8:55 PM
Edited Sep 23, 2011 at 8:56 PM
That code is unchanged. To get your SRC to compile I needed to remove references to your Zip and Log classes which weren't in the download. I think one of the XAML files also had a linefeed in it that stoped the dialog initialising.
The code I'm using is in a test solution that I can send you, ping me a mail: mattpil29 at g o o g l e m a i l dot com
Note setting _purgeInterval to 60 stops the problem in the code (because it doesn't use total minutes).
 
Matt

Sep 23, 2011 at 9:05 PM
Edited Sep 23, 2011 at 9:05 PM

The Test Client assumes you have the HSS Core framework installed (http://hsscore.codeplex.com).

I've done a little research and it appears XP handles File Times differently than Vista/7/2K8 but this is the first I've heard of anyone having issues like this.

There are some registry settings that affect this. For you it maybe disabled: http://www.liutilities.com/articles/disable-last-modified-accessed-timestamp-in-windows-xp/

I will be changing the purge to use TotalMinutes to support the Interval setting of up to 11 hours; thanks for catching that.

Sep 23, 2011 at 9:21 PM
Ok, I'll check. As I say if you increase the purge time to 60 or over you wouldn't see the issue.
Thanks and goodnight, Matt

On Fri, Sep 23, 2011 at 9:05 PM, hyspdrt <notifications@codeplex.com> wrote:

From: hyspdrt

The Test Client assumes you have the HSS Core framework installed (htpp://hsscore.codeplex.com).

I've done a little research and it appears XP handles File Times differently than Vista/7/2K8 but this is the first I've heard of anyone having issues like this.

There are some registry settings that affect this. For you it maybe disabled: http://www.liutilities.com/articles/disable-last-modified-accessed-timestamp-in-windows-xp/

I will be changing the purge to use TotalMinutes to support the Interval setting of up to 11 hours; thanks for catching that.

Read the full discussion online.

To add a post to this discussion, reply to this email (interlink@discussions.codeplex.com)

To start a new discussion for this project, email interlink@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com