Commit 0b5bbb3d authored by Robert Sprowson's avatar Robert Sprowson
Browse files

Fix for occasional divide-by-zero in filer copies

An else clause was being run for both the "write not complete" case but also when an error had occurred in an earlier step. The error would generally be a failure to create and hence a file size of zero. Bang.
Steps to recreate (other, more obscure and hard to catch cases exist)
 1. Open ResourceFS
 2. Copy Resources:$.Resources to Resources:$.Apps
 3. As ResourceFS is read only the reads all buffer OK but the first write (should return 'read only') gives divide-by-zero

Version 0.59. Tagged as 'FilerAct-0_59'
parent f59d8b6f
Syntax: *Filer_Action
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "0.58"
Module_Version SETA 58
Module_MajorVersion SETS "0.59"
Module_Version SETA 59
Module_MinorVersion SETS ""
Module_Date SETS "16 Aug 2012"
Module_ApplicationDate SETS "16-Aug-12"
Module_Date SETS "05 Apr 2013"
Module_ApplicationDate SETS "05-Apr-13"
Module_ComponentName SETS "FilerAct"
Module_ComponentPath SETS "castle/RiscOS/Sources/Desktop/FilerAct"
Module_FullVersion SETS "0.58"
Module_HelpVersion SETS "0.58 (16 Aug 2012)"
Module_FullVersion SETS "0.59"
Module_HelpVersion SETS "0.59 (05 Apr 2013)"
END
/* (0.58)
/* (0.59)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.58
#define Module_MajorVersion_CMHG 0.59
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 16 Aug 2012
#define Module_Date_CMHG 05 Apr 2013
#define Module_MajorVersion "0.58"
#define Module_Version 58
#define Module_MajorVersion "0.59"
#define Module_Version 59
#define Module_MinorVersion ""
#define Module_Date "16 Aug 2012"
#define Module_Date "05 Apr 2013"
#define Module_ApplicationDate "16-Aug-12"
#define Module_ApplicationDate "05-Apr-13"
#define Module_ComponentName "FilerAct"
#define Module_ComponentPath "castle/RiscOS/Sources/Desktop/FilerAct"
#define Module_FullVersion "0.58"
#define Module_HelpVersion "0.58 (16 Aug 2012)"
#define Module_LibraryVersionInfo "0:58"
#define Module_FullVersion "0.59"
#define Module_HelpVersion "0.59 (05 Apr 2013)"
#define Module_LibraryVersionInfo "0:59"
......@@ -1247,9 +1247,8 @@ os_error *read_a_block( BOOL *i_am_full, BOOL *need_another_file, BOOL *that_fin
*/
if ( next_fh_to_read() == NULL )
*need_another_file = Yes;
#ifdef USE_PROGRESS_BAR
}
#ifdef USE_PROGRESS_BAR
else
{
uint64_t p;
......@@ -1262,8 +1261,8 @@ os_error *read_a_block( BOOL *i_am_full, BOOL *need_another_file, BOOL *that_fin
*progress = (uint32_t) p;
debugmem(( "partial read: %u bytes / %u = %08x progress\n", b, fh->size, *progress ));
#endif
}
#endif
debugmem(( "X\n" ));
......@@ -1595,23 +1594,24 @@ static os_error *int_write_a_block( BOOL *i_am_empty, BOOL *that_finished_a_file
#endif
remove_file_from_chain();
#ifdef USE_PROGRESS_BAR
}
#ifdef USE_PROGRESS_BAR
else
{
uint64_t p;
uint32_t b;
uint64_t p;
uint32_t b;
b = fh->written_to - start_written_to;
p = (fh->total_progress * (uint64_t)b) / fh->size;
if ( err ) return err;
fh->write_progress -= (uint32_t) p;
*progress = (uint32_t) p;
b = fh->written_to - start_written_to; /* bytes written this time */
p = (fh->total_progress * (uint64_t)b) / fh->size;
debugmem(( "partial write: %u bytes / %u = %08x progress\n", b, fh->size, *progress ));
#endif
fh->write_progress -= (uint32_t) p;
*progress = (uint32_t) p;
debugmem(( "partial write: %u bytes / %u = %08x progress\n", b, fh->size, *progress ));
}
#endif
debugmem(( "X\n" ));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment