-- This function will return DONE if completed and BUSY if abandoned. Any other |
-- return would be a fatal error. |
::routine backupWithTimeLimit |
use strict arg buHandle, limit |
|
count = 0 |
do while .true |
ret = oosqlBackupStep(buHandle, 2) |
if ret == .ooSQLite~DONE then do |
say 'Backup finished with no error.' |
outcome = .ooSQLite~DONE |
leave |
end |
|
if ret >.<. .ooSQLite~OK, ret >.<. .ooSQLite~BUSY, ret >.<. .ooSQLite~LOCKED then do |
say 'Fatal error during back up.' |
outcome = ret |
leave |
end |
|
if count * 2 > limit then do |
say |
say "Backup has not completed within the time limit, going to abandon the operation." |
say |
outcome = .ooSQLite~BUSY |
leave |
end |
|
j = SysSleep(.5) |
count += 1 |
|
end |
|
ret = oosqlBackupFinish(buHandle) |
|
return outcome
|