It is currently Mon Sep 16, 2019 9:31 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Packer library enhancement
PostPosted: Sat Jul 20, 2019 11:14 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Apr 10, 2017 6:17 pm
Posts: 262
Location: Germany
If you use the packer library, you do stuff like
Code:
createpack()
addpackfile() / addpackmemory()
closepack()


and you always work with a "pack ID" you get by the createpack() command if you use #pb_any (unless you use a static ID).

My problem was, that if you want to reliably make sure an archive is physically written to the media, how do i achieve that? I wouldnt want to tell the user "Ok everything is fine" and instantly allow them to remove the media while actually the windows OS has the most recent change not written to the physical media, but just in a buffer/cache marked as "dirty" so at a later shutdown, it would be written to the media.

Imagine a user does a backup on a removeable media. The media could be removed before the changed cache is physically written to the media, therefore the media and archive would be in a corrupt state.

That is an old basic problem of all operating systems with removeable media. Unixes therefore "lock" the media and whoever removes the media without unlocking it first (aka ejecting it which writes all dirty cache pages physically to a media) ends up with an inconsistent logical media. PureBasic offers the flushfilebuffers command to avoid that. The problem is - the command requires a "fileid" but the packer library uses a packer library id.

So how to solve this problem officially to make the packer library reliably useable on removable media?

An official command like flushfilebuffers which works with a pack ID maybe? Alternatively an official way to get a file ID from an open packer library archive which can be used after closepack() - but that would seem a bit dirty for this usecase.

_________________
webpage


Top
 Profile  
Reply with quote  
 Post subject: Re: Packer library enhancement
PostPosted: Wed Aug 28, 2019 7:40 am 
Offline
Addict
Addict
User avatar

Joined: Sat Aug 15, 2009 6:59 pm
Posts: 1252
I would assume the file is completely written to disk after closepack(). Thats usually how OS handles disk writes, buffers are written to disk after the handle for the file is closed to prevent data loss on unexpected power loss, etc.
However it's up to the OS configuration if it still buffers after the handle is closed. PB does not offer a flushwritebuffer for the packer library.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye