* apt-pkg/depcache.cc:
authorMichael Vogt <michael.vogt@ubuntu.com>
Tue, 4 Jul 2006 07:22:49 +0000 (09:22 +0200)
committerMichael Vogt <michael.vogt@ubuntu.com>
Tue, 4 Jul 2006 07:22:49 +0000 (09:22 +0200)
  - create a empty state file if none exists

apt-pkg/depcache.cc

index 7663d38..25a4372 100644 (file)
@@ -186,6 +186,15 @@ bool pkgDepCache::writeStateFile(OpProgress *prog)
 
    FileFd StateFile;
    string state = _config->FindDir("Dir::State") + "extended_states";
+
+   // if it does not exist, create a empty one
+   if(!FileExists(state)) 
+   {
+      StateFile.Open(state, FileFd::WriteEmpty);
+      StateFile.Close();
+   }
+
+   // open it
    if(!StateFile.Open(state, FileFd::ReadOnly))
       return _error->Error(_("Failed to open StateFile %s"),
                           state.c_str());