code: def mark_done(self):
          
  
          # Recheck that this is not an segment explicitly passed from Postgres
          if self.explicit:
              raise UserCritical(
                  msg='unexpected attempt to modify wal metadata detected',
                  detail=('Segments explicitly passed from postgres should not '
                          'engage in archiver metadata manipulation: {0}'
                          .format(self.path)),
                  hint='report a bug')
  
          # Attempt a rename of archiver metadata, wrapping unexpected
          # raised exceptions into a UserCritical.
          try:
              status_dir = path.join(path.dirname(self.path),
                                     'archive_status')
  
              ready_metadata = path.join(status_dir, self.name + '.ready')
              done_metadata = path.join(status_dir, self.name + '.done')
  
              os.rename(ready_metadata, done_metadata)
          except Exception:
              raise UserCritical(
                  msg='problem moving .ready archive status to .done',
                  detail='Traceback is: {0}'.format(traceback.format_exc()),
                  hint='report a bug')
docs: Mark the archive status of this segment as 'done'.
  
          This is most useful when performing out-of-band parallel
          uploads of segments, so that Postgres doesn't try to go and
          upload them again.
  
          This amounts to messing with an internal bookkeeping mechanism
          of Postgres, but that mechanism is not changing too fast over
          the last five years and seems simple enough.