Gossamer Forum
Home : General : Perl Programming :

Stopping a large file getting corrupt?

Quote Reply
Stopping a large file getting corrupt?
Hi. I have a file that is 1.2Mb (A .db file, from Links 2).

I have got so far a script that opens up the file, puts all the content of it into an array, and then it goes through to check the status of the site (i.e. 404, 200 etc).

Now what I am trying to do is use a foreach loop to write the new data to links.db (the old file will be backed up to links.db.$date). However, it occured to me that seeing as there is over 4,000 links in the directory, what were to happen if the script were canceled (purposly or accidently). Would the whole file get corrupted too, or just the info that was being put in would not appear.

I have thought about writing the data to links.db.new, and then renaming it to links.db (after renaming the old copy). This would only happen at the end of the script, AFTER a successful go-through of the file.

Does this sound like a good idea, or are there better faster ones?

Thanks

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [AndyNewby] Stopping a large file getting corrupt? In reply to
Yea...nph-verify.cgi with LINKS SQL.

See ya.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [AnthroRules] Stopping a large file getting corrupt? In reply to
Dont have Links SQL Wink

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [AndyNewby] Stopping a large file getting corrupt? In reply to
Get it.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [AnthroRules] Stopping a large file getting corrupt? In reply to
As much as I would like a copy, I can't afford it Frown

I have enough bills without spending several hundred $'s on it Frown I just have to live with Links 2...lol

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [AndyNewby] Stopping a large file getting corrupt? In reply to
Sorry I don't understand the point of this. Why not just use the nph-verify.cgi script that comes with Links2.

This would be more approprite in the Links2 customization forum too.

Last edited by:

RedRum: Oct 12, 2001, 11:56 AM
Quote Reply
Re: [RedRum] Stopping a large file getting corrupt? In reply to
Never mind...I went with my idea anyway.

The reason I am writing a script is because it needs to check for 404's automatically, and if they are just delete them, and it also needs to check for reciprical links. Both of these nph-verify dont do, so i am writing my own Wink

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!

Last edited by:

AndyNewby: Oct 12, 2001, 12:01 PM
Quote Reply
Re: [AndyNewby] Stopping a large file getting corrupt? In reply to
um.. 3 file handles, old DB read 1 line at a time, printed to new DBs one at a time. It's generally bad practice to slurp large files... If you successfully reach the EOF character, then you can then set a variable to "1". after you close your handles, rename the new links.db. you shouldn't have any problems.

--Philip
Links 2.0 moderator