Beispiel #1
0
 @Override
 public Value link(DataHandler h, int tabId) {
   if (fileName == null) {
     this.tableId = tabId;
     return this;
   }
   if (linked) {
     ValueLob copy = ValueLob.copy(this);
     copy.objectId = getNewObjectId(h);
     copy.tableId = tabId;
     String live = getFileName(h, copy.tableId, copy.objectId);
     copyFileTo(h, fileName, live);
     copy.fileName = live;
     copy.linked = true;
     return copy;
   }
   if (!linked) {
     this.tableId = tabId;
     String live = getFileName(h, tableId, objectId);
     if (tempFile != null) {
       tempFile.stopAutoDelete();
       tempFile = null;
     }
     renameFile(h, fileName, live);
     fileName = live;
     linked = true;
   }
   return this;
 }
Beispiel #2
0
 @Override
 public void unlink(DataHandler handler) {
   if (linked && fileName != null) {
     String temp;
     // synchronize on the database, to avoid concurrent temp file
     // creation / deletion / backup
     synchronized (handler) {
       temp = getFileName(handler, -1, objectId);
       deleteFile(handler, temp);
       renameFile(handler, fileName, temp);
       tempFile = FileStore.open(handler, temp, "rw");
       tempFile.autoDelete();
       tempFile.closeSilently();
       fileName = temp;
       linked = false;
     }
   }
 }