-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ZBUG-4409: Missing Blobs on a restored account from backup with S3 storage #1698
base: develop
Are you sure you want to change the base?
Changes from 1 commit
03132c3
3d07956
6ec2421
0a80da4
214fd03
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -44,6 +44,7 @@ | |||||
import com.zimbra.cs.store.StagedBlob; | ||||||
import com.zimbra.cs.store.StoreManager; | ||||||
import com.zimbra.cs.store.file.VolumeMailboxBlob; | ||||||
import com.zimbra.cs.volume.Volume; | ||||||
|
||||||
/** | ||||||
* Abstract base class for external store integration. | ||||||
|
@@ -272,6 +273,31 @@ public StagedBlob stage(Blob blob, Mailbox mbox) throws IOException, ServiceExce | |||||
} | ||||||
} | ||||||
|
||||||
public StagedBlob stage(Blob blob, Mailbox mbox, Volume volume) throws IOException, ServiceException { | ||||||
if (supports(StoreFeature.RESUMABLE_UPLOAD) && blob instanceof ExternalUploadedBlob) { | ||||||
ZimbraLog.store.debug("blob already uploaded, just need to commit"); | ||||||
String locator = ((ExternalResumableUpload) this).finishUpload((ExternalUploadedBlob) blob); | ||||||
if (locator != null) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
ZimbraLog.store.debug("wrote to locator %s",locator); | ||||||
preshitaagrawal marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
localCache.put(locator, getContent(blob)); | ||||||
} else { | ||||||
ZimbraLog.store.warn("blob staging returned null locator"); | ||||||
} | ||||||
return new ExternalStagedBlob(mbox, blob.getDigest(), blob.getRawSize(), locator); | ||||||
} else { | ||||||
InputStream is = getContent(blob); | ||||||
try { | ||||||
StagedBlob staged = stage(is, blob.getRawSize(), mbox, volume); | ||||||
if (staged != null && staged.getLocator() != null) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
localCache.put(staged.getLocator(), getContent(blob)); | ||||||
} | ||||||
return staged; | ||||||
} finally { | ||||||
ByteUtil.closeStream(is); | ||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
@Override | ||||||
public StagedBlob stage(InputStream in, long actualSize, Mailbox mbox) throws ServiceException, IOException { | ||||||
if (actualSize < 0) { | ||||||
|
@@ -303,7 +329,35 @@ public StagedBlob stage(InputStream in, long actualSize, Mailbox mbox) throws Se | |||||
} | ||||||
} | ||||||
|
||||||
public StagedBlob stage(InputStream in, long actualSize, Mailbox mbox, Volume volume) throws ServiceException, IOException { | ||||||
if (actualSize < 0) { | ||||||
Blob blob = storeIncoming(in); | ||||||
try { | ||||||
return stage(blob, mbox, volume); | ||||||
} finally { | ||||||
quietDelete(blob); | ||||||
} | ||||||
} | ||||||
MessageDigest digest; | ||||||
try { | ||||||
digest = MessageDigest.getInstance("SHA-256"); | ||||||
} catch (NoSuchAlgorithmException e) { | ||||||
throw ServiceException.FAILURE("SHA-256 digest not found", e); | ||||||
} | ||||||
ByteUtil.PositionInputStream pin = new ByteUtil.PositionInputStream(new DigestInputStream(in, digest)); | ||||||
|
||||||
try { | ||||||
String locator = writeStreamToStore(pin, actualSize, mbox, volume.getId()); | ||||||
if (locator != null) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
ZimbraLog.store.debug("wrote to locator %s",locator); | ||||||
Gopal-Moolchandani marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
} else { | ||||||
ZimbraLog.store.warn("blob staging returned null locator"); | ||||||
} | ||||||
return new ExternalStagedBlob(mbox, ByteUtil.encodeFSSafeBase64(digest.digest()), pin.getPosition(), locator); | ||||||
} catch (IOException e) { | ||||||
throw ServiceException.FAILURE("unable to stage blob", e); | ||||||
} | ||||||
} | ||||||
@Override | ||||||
public Blob storeIncoming(InputStream data, boolean storeAsIs) throws IOException, | ||||||
ServiceException { | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,6 +118,12 @@ public VolumeStagedBlob stage(InputStream in, long actualSize, Mailbox mbox) | |
return new VolumeStagedBlob(mbox, (VolumeBlob) blob).markStagedDirectly(); | ||
} | ||
|
||
@Override | ||
public StagedBlob stage(InputStream data, long actualSize, Mailbox mbox, Volume volume) throws IOException, ServiceException { | ||
// mailbox store is on the same volume as incoming directory, so no need to stage the blob | ||
throw ServiceException.FAILURE("Operation can not be completed because ExternalStoreManager is not available", null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is not necessary this method will be always executed for external storage, this message should be generic |
||
} | ||
|
||
@Override | ||
public VolumeStagedBlob stage(Blob blob, Mailbox mbox) throws IOException { | ||
// mailbox store is on the same volume as incoming directory, so no need to stage the blob | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of hard code value can we declare variable for -1 , because its confusing