Commit 2c9c1d36 authored by Bernhard Link's avatar Bernhard Link

rework handling of files added to the pool not used by anything, by moving it...

rework handling of files added to the pool not used by anything, by moving it into the new unreferenced file handling
parent 7c7c3208
2008-11-03
* rework handling of files added to the pool not used by anything.
(for example because the package was not added due to error).
New --keepunusednewfiles option to not delete such files.
2008-11-01
* print number of newly unreferenced file on --keepunreferenced
and commands not deleting their references.
......
......@@ -583,7 +583,7 @@ retvalue binaries_complete(const struct deb_headers *pkg, const char *filekey, c
return RET_OK;
}
retvalue binaries_adddeb(const struct deb_headers *deb, struct database *database, architecture_t forcearchitecture, packagetype_t packagetype, struct distribution *distribution, struct trackingdata *trackingdata, component_t component, const struct strlist *filekeys, bool *usedmarker, const char *control) {
retvalue binaries_adddeb(const struct deb_headers *deb, struct database *database, architecture_t forcearchitecture, packagetype_t packagetype, struct distribution *distribution, struct trackingdata *trackingdata, component_t component, const struct strlist *filekeys, const char *control) {
retvalue r,result;
int i;
......@@ -607,7 +607,7 @@ retvalue binaries_adddeb(const struct deb_headers *deb, struct database *databas
database,
deb->name, deb->version,
control,
filekeys, usedmarker,
filekeys,
false,
trackingdata,
deb->architecture_atom);
......@@ -629,7 +629,7 @@ retvalue binaries_adddeb(const struct deb_headers *deb, struct database *databas
database,
deb->name, deb->version,
control,
filekeys, usedmarker,
filekeys,
false,
trackingdata,
deb->architecture_atom);
......@@ -655,7 +655,7 @@ retvalue binaries_adddeb(const struct deb_headers *deb, struct database *databas
database,
deb->name, deb->version,
control,
filekeys, usedmarker,
filekeys,
false,
trackingdata,
deb->architecture_atom);
......
......@@ -51,6 +51,6 @@ retvalue binaries_calcfilekeys(component_t, const struct deb_headers *, packaget
struct overrideinfo;
retvalue binaries_complete(const struct deb_headers *, const char *filekey, const struct checksums *, const struct overrideinfo *, const char *section, const char *priority, char **newcontrol);
retvalue binaries_adddeb(const struct deb_headers *, struct database *, architecture_t forcedarchitecture, packagetype_t, struct distribution *, /*@null@*/struct trackingdata *, component_t, const struct strlist *filekeys, bool *usedmarker, const char *control);
retvalue binaries_adddeb(const struct deb_headers *, struct database *, architecture_t forcedarchitecture, packagetype_t, struct distribution *, /*@null@*/struct trackingdata *, component_t, const struct strlist *filekeys, const char *control);
retvalue binaries_checkadddeb(const struct deb_headers *, struct database *, architecture_t forcearchitecture, packagetype_t, struct distribution *, bool tracking, component_t, bool permitnewerold);
#endif
......@@ -87,7 +87,6 @@ struct fileentry {
char *filekey;
/* was already found in the pool before */
bool wasalreadythere;
bool included;
/* set between checkpkg and includepkg */
struct strlist needed_filekeys;
union { struct dsc_headers dsc;
......@@ -110,7 +109,6 @@ struct changes {
component_t srccomponent;
/* != NULL if changesfile was put into pool/ */
/*@null@*/ char *changesfilekey;
bool includedchangesfile;
/* the directory where source files are put into */
char *srcdirectory;
/* (only to warn if multiple are used) */
......@@ -799,61 +797,15 @@ static retvalue changes_includefiles(struct database *database,struct changes *c
if( e->wasalreadythere && checksums_iscomplete(e->checksums) )
continue;
e->included = false;
r = files_checkincludefile(database,
changes->incomingdirectory, e->basename,
e->filekey, &e->checksums, &e->included);
e->filekey, &e->checksums);
if( RET_WAS_ERROR(r) )
return r;
assert( e->included || e->wasalreadythere );
assert( !(e->included && e->wasalreadythere) );
}
return r;
}
/* run if packages are not all includeable and the stuff put into the
* pool shall be removed again */
static void changes_unincludefiles(struct database *database,struct changes *changes) {
struct fileentry *e;
for( e = changes->files; e != NULL ; e = e->next ) {
if( e->filekey == NULL || e->wasalreadythere || !e->included )
continue;
(void)files_deleteandremove(database, e->filekey, false);
}
if( changes->includedchangesfile )
(void)files_deleteandremove(database, changes->changesfilekey,
false);
}
static void check_all_files_included(struct database *database, struct changes *changes, bool unusedpartsexpected) {
struct fileentry *e;
retvalue r;
for( e = changes->files; e != NULL ; e = e->next ) {
if( e->filekey == NULL || e->wasalreadythere || !e->included )
continue;
if( unusedpartsexpected ) {
(void)files_deleteandremove(database, e->filekey, false);
continue;
}
fprintf(stderr, "Warning: File '%s' was listed in the .changes\n"
" but seems unused. Checking for references...\n",
e->filekey);
r = references_isused(database, e->filekey);
if( r == RET_NOTHING ) {
fprintf(stderr, " indeed unused, deleting it...\n");
(void)files_deleteandremove(database, e->filekey, false);
} else if( RET_IS_OK(r) ) {
fprintf(stderr, " It looks used. Strange. Please report this bug.\n");
}
}
}
/* delete the files included */
static retvalue changes_deleteleftoverfiles(struct changes *changes,int delete) {
......@@ -891,7 +843,6 @@ static retvalue changes_deleteleftoverfiles(struct changes *changes,int delete)
static retvalue changes_check_sourcefile(struct changes *changes, struct fileentry *dsc, struct database *database, const char *basefilename, const char *filekey, struct checksums **checksums_p) {
retvalue r;
bool dummy = false;
r = files_expect(database, filekey, *checksums_p);
if( RET_WAS_ERROR(r) )
......@@ -913,10 +864,8 @@ static retvalue changes_check_sourcefile(struct changes *changes, struct fileent
"Perhaps you forgot to give dpkg-buildpackage the -sa option.\n"
"--ignore=missingfile was given, searching for file...\n", filekey);
// TODO: if this is included and a error occours, it currently stays.
// how can this be fixed?
return files_checkincludefile(database, changes->incomingdirectory,
basefilename, filekey, checksums_p, &dummy);
basefilename, filekey, checksums_p);
}
static retvalue dsc_prepare(struct changes *changes, struct fileentry *dsc, struct database *database, struct distribution *distribution, const char *dscfilename){
......@@ -1093,7 +1042,6 @@ static retvalue changes_checkpkgs(struct database *database, struct distribution
static retvalue changes_includepkgs(struct database *database, struct distribution *distribution, struct changes *changes, /*@null@*/struct trackingdata *trackingdata, bool *missed_p) {
struct fileentry *e;
retvalue result,r;
bool markedasused;
*missed_p = false;
r = distribution_prepareforwriting(distribution);
......@@ -1110,43 +1058,25 @@ static retvalue changes_includepkgs(struct database *database, struct distributi
}
if( interrupted() )
return RET_ERROR_INTERRUPTED;
markedasused = false;
if( e->type == fe_DEB ) {
r = deb_addprepared(e->pkg.deb, database,
e->architecture_into, pt_deb,
distribution, trackingdata, &markedasused);
distribution, trackingdata);
if( r == RET_NOTHING )
*missed_p = true;
if( markedasused )
e->included = false;
} else if( e->type == fe_UDEB ) {
r = deb_addprepared(e->pkg.deb, database,
e->architecture_into, pt_udeb,
distribution, trackingdata, &markedasused);
distribution, trackingdata);
if( r == RET_NOTHING )
*missed_p = true;
if( markedasused )
e->included = false;
} else if( e->type == fe_DSC ) {
r = dsc_addprepared(database, &e->pkg.dsc,
changes->srccomponent,
&e->needed_filekeys, &markedasused,
&e->needed_filekeys,
distribution, trackingdata);
if( r == RET_NOTHING )
*missed_p = true;
if( markedasused ) {
struct fileentry *f;
const struct strlist *referenced = &e->needed_filekeys;
/* mark any file no longer allowed to be deleted */
for( f = changes->files ; f != NULL ; f = f->next ) {
if( !f->included )
continue;
if( strlist_in(referenced, f->filekey) )
f->included = false;
}
}
}
RET_UPDATE(result, r);
......@@ -1254,7 +1184,6 @@ retvalue changes_add(struct database *database, trackingdb const tracks, package
r = changes_checkpkgs(database, distribution, changes);
if( RET_WAS_ERROR(r) ) {
changes_unincludefiles(database, changes);
changes_free(changes);
return r;
}
......@@ -1262,7 +1191,6 @@ retvalue changes_add(struct database *database, trackingdb const tracks, package
if( tracks != NULL ) {
r = trackingdata_summon(tracks,changes->source,changes->sourceversion,&trackingdata);
if( RET_WAS_ERROR(r) ) {
changes_unincludefiles(database, changes);
changes_free(changes);
return r;
}
......@@ -1278,7 +1206,6 @@ retvalue changes_add(struct database *database, trackingdb const tracks, package
basefilename);
free(basefilename);
if( changes->changesfilekey == NULL ) {
changes_unincludefiles(database, changes);
changes_free(changes);
trackingdata_done(&trackingdata);
return RET_ERROR_OOM;
......@@ -1289,9 +1216,8 @@ retvalue changes_add(struct database *database, trackingdb const tracks, package
r = files_preinclude(database,
changesfilename,
changes->changesfilekey,
NULL, &changes->includedchangesfile);
NULL);
if( RET_WAS_ERROR(r) ) {
changes_unincludefiles(database, changes);
changes_free(changes);
trackingdata_done(&trackingdata);
return r;
......@@ -1301,7 +1227,6 @@ retvalue changes_add(struct database *database, trackingdb const tracks, package
if( interrupted() ) {
if( tracks != NULL )
trackingdata_done(&trackingdata);
changes_unincludefiles(database, changes);
changes_free(changes);
return RET_ERROR_INTERRUPTED;
}
......@@ -1314,13 +1239,10 @@ retvalue changes_add(struct database *database, trackingdb const tracks, package
if( tracks != NULL ) {
trackingdata_done(&trackingdata);
}
changes_unincludefiles(database, changes);
changes_free(changes);
return result;
}
check_all_files_included(database, changes, somethingwasmissed);
if( tracks != NULL ) {
if( changes->changesfilekey != NULL ) {
char *changesfilekey = strdup(changes->changesfilekey);
......@@ -1335,8 +1257,6 @@ retvalue changes_add(struct database *database, trackingdb const tracks, package
ft_CHANGES, changesfilekey, false,
database);
RET_ENDUPDATE(result,r);
/* no longer delete when done */
changes->includedchangesfile = false;
}
r = trackingdata_finish(tracks, &trackingdata, database);
RET_ENDUPDATE(result,r);
......
......@@ -269,10 +269,10 @@ retvalue deb_prepare(/*@out@*/struct debpackage **deb, component_t forcecomponen
return RET_OK;
}
retvalue deb_addprepared(const struct debpackage *pkg, struct database *database, architecture_t forcearchitecture, packagetype_t packagetype, struct distribution *distribution, struct trackingdata *trackingdata, bool *usedmarker) {
retvalue deb_addprepared(const struct debpackage *pkg, struct database *database, architecture_t forcearchitecture, packagetype_t packagetype, struct distribution *distribution, struct trackingdata *trackingdata) {
return binaries_adddeb(&pkg->deb, database, forcearchitecture,
packagetype, distribution, trackingdata,
pkg->component_atom, &pkg->filekeys, usedmarker,
pkg->component_atom, &pkg->filekeys,
pkg->deb.control);
}
......@@ -287,7 +287,6 @@ retvalue deb_add(struct database *database, component_t forcecomponent, architec
const struct overrideinfo *oinfo;
char *control;
struct checksums *checksums;
bool fileused = false;
causingfile = debfilename;
......@@ -300,9 +299,7 @@ retvalue deb_add(struct database *database, component_t forcecomponent, architec
deb_free(pkg);
return r;
}
r = files_preinclude(database, debfilename, pkg->filekey, &checksums,
&fileused);
fileused = !fileused;
r = files_preinclude(database, debfilename, pkg->filekey, &checksums);
if( RET_WAS_ERROR(r) ) {
deb_free(pkg);
return r;
......@@ -312,8 +309,6 @@ retvalue deb_add(struct database *database, component_t forcecomponent, architec
pkg->deb.section, pkg->deb.priority, &control);
checksums_free(checksums);
if( RET_WAS_ERROR(r) ) {
if( !fileused )
files_deleteandremove(database, pkg->filekey, false);
deb_free(pkg);
return r;
}
......@@ -325,9 +320,6 @@ retvalue deb_add(struct database *database, component_t forcecomponent, architec
pkg->deb.source, pkg->deb.sourceversion,
&trackingdata);
if( RET_WAS_ERROR(r) ) {
if( !fileused )
files_deleteandremove(database, pkg->filekey,
false);
deb_free(pkg);
return r;
}
......@@ -336,11 +328,8 @@ retvalue deb_add(struct database *database, component_t forcecomponent, architec
r = binaries_adddeb(&pkg->deb, database, forcearchitecture,
packagetype, distribution,
(tracks!=NULL)?&trackingdata:NULL,
pkg->component_atom, &pkg->filekeys, &fileused,
pkg->component_atom, &pkg->filekeys,
pkg->deb.control);
assert( !RET_IS_OK(r) || fileused );
if( !fileused )
files_deleteandremove(database, pkg->filekey, false);
RET_UPDATE(distribution->status, r);
deb_free(pkg);
......
......@@ -22,7 +22,7 @@ retvalue deb_add(struct database *, component_t forcecomponent, architecture_t f
/* in two steps */
struct debpackage;
retvalue deb_addprepared(const struct debpackage *pkg, struct database *, architecture_t forcearchitecture, packagetype_t packagetype, struct distribution *distribution, struct trackingdata *trackingdata, bool *usedmarker);
retvalue deb_addprepared(const struct debpackage *, struct database *, architecture_t forcearchitecture, packagetype_t, struct distribution *, struct trackingdata *);
retvalue deb_prepare(/*@out@*/struct debpackage **deb, component_t forcecomponent, architecture_t forcearchitecture, const char *forcesection, const char *forcepriority, packagetype_t, struct distribution *distribution, const char *debfilename, const char * const filekey, const struct checksums *checksums, const struct strlist *allowed_binaries, const char *expectedsourcename, const char *expectedsourceversion);
void deb_free(/*@only@*/struct debpackage *pkg);
#endif
......@@ -87,24 +87,10 @@ struct dscpackage {
component_t component_atom;
/* Things that may be calculated by dsc_calclocations: */
struct strlist filekeys;
/* if set, everything set to true should be deleted when not used */
/*@null@*/bool *deleteonfailure;
};
static void dsc_free(/*@only@*/struct dscpackage *pkg, struct database *database) {
if( pkg != NULL ) {
if( pkg->deleteonfailure != NULL ) {
int i;
for( i = 0 ; i < pkg->filekeys.count ; i++ ) {
if( pkg->deleteonfailure[i] )
files_deleteandremove(
database,
pkg->filekeys.values[i],
false);
}
free(pkg->deleteonfailure);
}
sources_done(&pkg->dsc);
strlist_done(&pkg->filekeys);
free(pkg);
......@@ -141,7 +127,7 @@ static retvalue dsc_read(/*@out@*/struct dscpackage **pkg, const char *filename)
return RET_OK;
}
retvalue dsc_addprepared(struct database *database, const struct dsc_headers *dsc, component_t component, const struct strlist *filekeys, bool *usedmarker, struct distribution *distribution, struct trackingdata *trackingdata){
retvalue dsc_addprepared(struct database *database, const struct dsc_headers *dsc, component_t component, const struct strlist *filekeys, struct distribution *distribution, struct trackingdata *trackingdata){
retvalue r;
struct target *t = distribution_getpart(distribution,
component, architecture_source, pt_dsc);
......@@ -158,7 +144,7 @@ retvalue dsc_addprepared(struct database *database, const struct dsc_headers *ds
r = target_addpackage(t, distribution->logger, database,
dsc->name, dsc->version,
dsc->control, filekeys,
usedmarker, false, trackingdata,
false, trackingdata,
architecture_source);
r2 = target_closepackagesdb(t);
RET_ENDUPDATE(r,r2);
......@@ -179,7 +165,6 @@ retvalue dsc_add(struct database *database, component_t forcecomponent, const ch
char *destdirectory, *origdirectory;
const struct overrideinfo *oinfo;
char *control;
bool usedmarker = false;
int i;
causingfile = dscfilename;
......@@ -310,12 +295,6 @@ retvalue dsc_add(struct database *database, component_t forcecomponent, const ch
atoms_components[pkg->component_atom]);
}
pkg->deleteonfailure = calloc(pkg->dsc.files.names.count+1, sizeof(bool));
if( pkg->deleteonfailure == NULL ) {
dsc_free(pkg, database);
return RET_ERROR_OOM;
}
{ char *dscbasename, *dscfilekey;
struct checksums *dscchecksums;
......@@ -340,7 +319,7 @@ retvalue dsc_add(struct database *database, component_t forcecomponent, const ch
/* then look if we already have this, or copy it in */
r = files_preinclude(database,
dscfilename, dscfilekey,
&dscchecksums, &pkg->deleteonfailure[0]);
&dscchecksums);
if( !RET_WAS_ERROR(r) ) {
/* Add the dsc-file to basenames,filekeys and md5sums,
......@@ -365,8 +344,7 @@ retvalue dsc_add(struct database *database, component_t forcecomponent, const ch
r = files_checkincludefile(database, origdirectory,
pkg->dsc.files.names.values[i],
pkg->filekeys.values[i],
&pkg->dsc.files.checksums[i],
&pkg->deleteonfailure[i]);
&pkg->dsc.files.checksums[i]);
}
}
......@@ -401,13 +379,8 @@ retvalue dsc_add(struct database *database, component_t forcecomponent, const ch
}
r = dsc_addprepared(database, &pkg->dsc, pkg->component_atom,
&pkg->filekeys, &usedmarker,
distribution,
&pkg->filekeys, distribution,
(tracks!=NULL)?&trackingdata:NULL);
if( usedmarker ) {
for( i = 0 ; i < pkg->dsc.files.names.count ; i++ )
pkg->deleteonfailure[i] = false;
}
/* delete source files, if they are to be */
if( ( RET_IS_OK(r) && delete >= D_MOVE ) ||
......
......@@ -26,6 +26,6 @@ retvalue dsc_add(struct database *, component_t, /*@null@*/const char *forcesect
* delete should be D_INPLACE then
*/
retvalue dsc_addprepared(struct database *, const struct dsc_headers *, component_t , const struct strlist *filekeys, bool *usedmarker, struct distribution *distribution, /*@null@*/struct trackingdata *trackingdata);
retvalue dsc_addprepared(struct database *, const struct dsc_headers *, component_t , const struct strlist *filekeys, struct distribution *distribution, /*@null@*/struct trackingdata *trackingdata);
#endif
......@@ -272,7 +272,7 @@ static retvalue package_add(struct database *database, struct distribution *into
into->logger, database,
package->name, package->version,
package->control,
&package->filekeys, NULL, true,
&package->filekeys, true,
(tracks != NULL)?
&trackingdata:NULL,
package->architecture);
......
......@@ -211,6 +211,13 @@ Do not delete files that are no longer used because the package they
are from is deleted/replaced with a newer version from the last distribution
it was in.
.TP
.B \-\-keepunusednewfiles
The include, includedsc, includedeb and processincoming by default delete
any file they added to the pool that is not marked used at the end of the
operation.
While this keeps the pool clean and allows changing before trying to add again,
this needs copying and checksum calculation every time one tries to add a file.
.TP
.B \-\-keepdirectories
Do not try to rmdir parent directories after files or directories
have been removed from them.
......
......@@ -105,7 +105,7 @@ _reprepro()
surprisingbinary wrongsourceversion wrongversion dscinbinnmu\
brokensignatures uploaders missingfile'
noargoptions='--delete --nodelete --help -h --verbose -v\
--nothingiserror --nolistsdownload --keepunreferencedfiles\
--nothingiserror --nolistsdownload --keepunreferencedfiles --keepunusednewfiles\
--keepdirectories\
--ask-passphrase --nonothingiserror --listsdownload\
--nokeepunreferencesfiles --nokeepdirectories\
......
......@@ -303,6 +303,7 @@ _arguments \
'(--nonothingiserror)--nothingiserror[Return error code when nothing was done]' \
'(--listsdownload --nonolistsdownload)--nolistsdownload[Do not download Release nor index files]' \
'(--nokeepunreferencedfiles)--keepunreferencedfiles[Do not delete files that are no longer used]' \
'(--nokeepunusednewfiles)--keepunusednewfiles[Do not delete newly added files that later were found to not be used]' \
'(--nokeepdirectories)--keepdirectories[Do not remove directories when they get emtpy]' \
'(--noask-passphrase)--ask-passphrase[Ask for passphrases (insecure)]' \
'(--nonoskipold --skipold)--noskipold[Do not ignore parts where no new index file is available]' \
......
......@@ -36,6 +36,7 @@
#include "ignore.h"
#include "filelist.h"
#include "debfile.h"
#include "pool.h"
#include "database_p.h"
static retvalue files_get_checksums(struct database *database, const char *filekey, /*@out@*/struct checksums **checksums_p) {
......@@ -80,8 +81,11 @@ retvalue files_add_checksums(struct database *database, const char *filekey, con
r = checksums_getcombined(checksums, &combined, &combinedlen);
if( !RET_IS_OK(r) )
return r;
return table_adduniqsizedrecord(database->checksums, filekey,
r = table_adduniqsizedrecord(database->checksums, filekey,
combined, combinedlen + 1, true, false);
if( !RET_IS_OK(r) )
return r;
return pool_markadded(filekey);
}
static retvalue files_replace_checksums(struct database *database, const char *filekey, const struct checksums *checksums) {
......@@ -105,7 +109,7 @@ static retvalue files_replace_checksums(struct database *database, const char *f
}
/* remove file's md5sum from database */
retvalue files_remove(struct database *database, const char *filekey, bool ignoremissing) {
retvalue files_removesilent(struct database *database, const char *filekey) {
retvalue r;
if( database->contents != NULL ) {
......@@ -114,14 +118,14 @@ retvalue files_remove(struct database *database, const char *filekey, bool ignor
if( database->oldmd5sums != NULL ) {
(void)table_deleterecord(database->checksums, filekey, true);
r = table_deleterecord(database->oldmd5sums, filekey, true);
if( r == RET_NOTHING && !ignoremissing ) {
if( r == RET_NOTHING ) {
fprintf(stderr, "Unable to forget unknown filekey '%s'.\n",
filekey);
return RET_ERROR_MISSING;
}
} else {
r = table_deleterecord(database->checksums, filekey, true);
if( r == RET_NOTHING && !ignoremissing ) {
if( r == RET_NOTHING ) {
fprintf(stderr, "Unable to forget unknown filekey '%s'.\n",
filekey);
return RET_ERROR_MISSING;
......@@ -130,16 +134,24 @@ retvalue files_remove(struct database *database, const char *filekey, bool ignor
return r;
}
/* delete the file and remove its md5sum from database */
retvalue files_deleteandremove(struct database *database, const char *filekey, bool ignoreifnot) {
retvalue files_remove(struct database *database, const char *filekey) {
retvalue r;
r = files_removesilent(database, filekey);
if( RET_IS_OK(r) ) {
return pool_markdeleted(filekey);
}
return r;
}
/* delete the file and possible parent directories */
retvalue files_deletefile(struct database *database, const char *filekey) {
int err,en;
char *filename;
retvalue r;
if( interrupted() )
return RET_ERROR_INTERRUPTED;
if( verbose >= 1 )
printf("deleting and forgetting %s\n",filekey);
filename = files_calcfullfilename(database, filekey);
if( filename == NULL )
return RET_ERROR_OOM;
......@@ -148,8 +160,8 @@ retvalue files_deleteandremove(struct database *database, const char *filekey, b
en = errno;
r = RET_ERRNO(en);
if( errno == ENOENT ) {
if( !ignoreifnot )
fprintf(stderr,"%s not found, forgetting anyway\n",filename);
fprintf(stderr,"%s not found, forgetting anyway\n",filename);
return RET_NOTHING;
} else {
fprintf(stderr, "error %d while unlinking %s: %s\n",
en, filename, strerror(en));
......@@ -194,7 +206,7 @@ retvalue files_deleteandremove(struct database *database, const char *filekey, b
}
free(filename);
return files_remove(database, filekey, ignoreifnot);
return RET_OK;
}
/* hardlink file with known checksums and add it to database */
......@@ -949,7 +961,7 @@ retvalue files_regenerate_filelist(struct database *database, bool reread) {
}
/* Include a yet unknown file into the pool */
retvalue files_preinclude(struct database *database, const char *sourcefilename, const char *filekey, struct checksums **checksums_p, bool *newlyadded_p) {
retvalue files_preinclude(struct database *database, const char *sourcefilename, const char *filekey, struct checksums **checksums_p) {
retvalue r;
struct checksums *checksums, *realchecksums;
bool improves;
......@@ -959,8 +971,6 @@ retvalue files_preinclude(struct database *database, const char *sourcefilename,
if( RET_WAS_ERROR(r) )
return r;
if( RET_IS_OK(r) ) {
*newlyadded_p = false;
r = checksums_read(sourcefilename, &realchecksums);
if( r == RET_NOTHING )
r = RET_ERROR_MISSING;
......@@ -1020,7 +1030,6 @@ retvalue files_preinclude(struct database *database, const char *sourcefilename,
return r;
}
free(fullfilename);
*newlyadded_p = true;
r = files_add_checksums(database, filekey, checksums);
if( RET_WAS_ERROR(r) ) {
......@@ -1121,7 +1130,7 @@ static retvalue checkimproveorinclude(struct database *database, const char *sou
return r;
}
retvalue files_checkincludefile(struct database *database, const char *sourcedir, const char *basefilename, const char *filekey, struct checksums **checksums_p, bool *newlyincluded_p) {
retvalue files_checkincludefile(struct database *database, const char *sourcedir, const char *basefilename, const char *filekey, struct checksums **checksums_p) {
char *sourcefilename, *fullfilename;
struct checksums *checksums;
retvalue r;
......@@ -1129,7 +1138,6 @@ retvalue files_checkincludefile(struct database *database, const char *sourcedir
assert( *checksums_p != NULL );
*newlyincluded_p = false;
r = files_get_checksums(database, filekey, &checksums);
if( RET_WAS_ERROR(r) )
return r;
......@@ -1204,8 +1212,7 @@ retvalue files_checkincludefile(struct database *database, const char *sourcedir
fprintf(stderr, "ERROR: Unexpected content of file '%s'!\n", sourcefilename);
checksums_printdifferences(stderr, *checksums_p, checksums);
r = RET_ERROR_WRONG_MD5;
} else
*newlyincluded_p = true;
}
free(sourcefilename);
free(fullfilename);
if( RET_WAS_ERROR(r) ) {
......
......@@ -16,11 +16,12 @@ struct checksumsarray;
retvalue files_add_checksums(struct database *, const char *, const struct checksums *);
/* remove file's md5sum from database */
retvalue files_remove(struct database *, const char *filekey, bool ignoremissing);
retvalue files_remove(struct database *, const char *filekey);
/* same but do not call pool_markremoved */
retvalue files_removesilent(struct database *, const char *filekey);
/* delete the file and remove its md5sum from database,
* also try to rmdir empty directories it is in if rmdirs is true */
retvalue files_deleteandremove(struct database *, const char *filekey, bool ignoremissing);
/* delete the filekey (not doing anything else, not even forgetting it) */
retvalue files_deletefile(struct database *, const char *);
/* check for file in the database and if not found there in the pool */
retvalue files_expect(struct database *, const char *, const struct checksums *);
......@@ -47,8 +48,8 @@ retvalue files_printmissing(struct database *, const struct strlist *filekeys, c
* return RET_ERROR_WRONG_MD5 if wrong md5sum.
* (the original file is not deleted in that case, even if delete is positive)
*/
retvalue files_preinclude(struct database *, const char *sourcefilename, const char *filekey, /*@null@*//*@out@*/struct checksums **, /*@out@*/bool *);
retvalue files_checkincludefile(struct database *, const char *directory, const char *sourcefilename, const char *filekey, struct checksums **, /*@out@*/bool *);
retvalue files_preinclude(struct database *, const char *sourcefilename, const char *filekey, /*@null@*//*@out@*/struct checksums **);
retvalue files_checkincludefile(struct database *, const char *directory, const char *sourcefilename, const char *filekey, struct checksums **);
typedef retvalue per_file_action(void *data, const char *filekey);
......
......@@ -1292,32 +1292,6 @@ static retvalue prepare_for_distribution(struct database *database,const struct
return RET_OK;
}
static retvalue candidate_removefiles(struct database *database,struct candidate *c,struct candidate_perdistribution *stopat,struct candidate_package *stopatatstopat,int stopatatstopatatstopat) {
int j;
struct candidate_perdistribution *d;
struct candidate_package *p;
retvalue r;
for( d = c->perdistribution ; d != NULL ; d = d->next ) {
for( p = d->packages ; p != NULL ; p = p->next ) {
for( j = 0 ; j < p->filekeys.count ; j++ ) {
if( d == stopat &&
p == stopatatstopat &&
j >= stopatatstopatatstopat )
return RET_OK;
if( p->files[j] == NULL )
continue;
r = files_deleteandremove(database,
p->filekeys.values[j], true);
if( RET_WAS_ERROR(r) )
return r;
}
}
}
return RET_OK;
}
static retvalue candidate_addfiles(struct database *database,struct candidate *c) {
int j;
struct candidate_perdistribution *d;
......@@ -1337,14 +1311,8 @@ static retvalue candidate_addfiles(struct database *database,struct candidate *c
f->tempfilename,
p->filekeys.values[j],
f->checksums);
if( !RET_IS_OK(r) )
/* when we did not add it, do not remove it: */
p->files[j] = NULL;
if( RET_WAS_ERROR(r) ) {
(void)candidate_removefiles(database,
c, d, p, j);
if( RET_WAS_ERROR(r) )
return r;
}
}
}
}
......@@ -1355,8 +1323,6 @@ static retvalue add_dsc(struct database *database, struct distribution *into, st
retvalue r;
struct target *t = distribution_getpart(into,
p->component_atom, architecture_source, pt_dsc);
// TODO: use this information:
bool usedmarker = false;
assert( logger_isprepared(into->logger) );
......@@ -1371,7 +1337,7 @@ static retvalue add_dsc(struct database *database, struct distribution *into, st
p->master->dsc.name,
p->master->dsc.version,
p->control,
&p->filekeys, &usedmarker,
&p->filekeys,
false, trackingdata,
architecture_source);
r2 = target_closepackagesdb(t);
......@@ -1462,14 +1428,12 @@ static retvalue candidate_add_into(struct database *database, const struct incom
(tracks==NULL)?NULL:&trackingdata,
p);
} else if( FE_BINARY(p->master->type) ) {
// TODO: use this information?
bool usedmarker = false;